diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index ab3917c1..8a81def7 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -36,22 +36,16 @@ jobs: testPreset: "ci-${{matrix.os}}" - name: artifacts uses: actions/upload-artifact@v3 - if: ${{ github.ref == 'ref/head/main' }} with: name: build-${{matrix.os}} path: | - build - !build/tests - !build/Testing - !build/CMakeFiles - !build/DartConfiguration.tcl - !build/CTestTestfile.cmake - !build/CMakeCache.txt - !build/build.ninja - !build/_deps - !build/cmake_install.cmake - !build/*.a - !build/*.lib - !build/*.dir - !build/*.vcxproj - !build/*.vcxproj.filters + build/*Server* + build/*.ini + build/*.so + build/*.dll + build/vanity/ + build/navmeshes/ + build/migrations/ + build/*.dcf + !build/*.pdb + !build/d*/ diff --git a/README.md b/README.md index df782a32..f51b5e2a 100644 --- a/README.md +++ b/README.md @@ -245,30 +245,11 @@ To connect to a server follow these steps: * In the client directory, locate `boot.cfg` * Open it in a text editor and locate where it says `AUTHSERVERIP=0:` * Replace the contents after to `:` and the following `,` with what you configured as the server's public facing IP. For example `AUTHSERVERIP=0:localhost` for locally hosted servers +* Next locate the line `UGCUSE3DSERVICES=7:` +* Ensure the number after the 7 is a `0` * Launch `legouniverse.exe`, through `wine` if on a Unix-like operating system * Note that if you are on WSL2, you will need to configure the public IP in the server and client to be the IP of the WSL2 instance and not localhost, which can be found by running `ifconfig` in the terminal. Windows defaults to WSL1, so this will not apply to most users. -## Brick-By-Brick building -Should you choose to do any brick building, you will want to have some form of a http server that returns a 404 error since we are unable to emulate live User Generated Content at the moment. If you attempt to do any brick building without a 404 server running properly, you will be unable to load into your game. Python is the easiest way to do this, but any thing that returns a 404 should work fine. -* Note: the client hard codes this request on port 80. - -**If you do not plan on doing any Brick Building, then you can skip this step.** - -The easiest way to do this is to install [python](https://www.python.org/downloads/). - -### Allowing a user to build in Brick-by-Brick mode -Brick-By-Brick building requires `PATCHSERVERIP=0:` and `UGCSERVERIP=0:` in the `boot.cfg` to point to a HTTP server which always returns `HTTP 404 - Not Found` for all requests. This can be most easily achieved by pointing both of those variables to `localhost` while having running in the background. -Each client must have their own 404 server running if they are using a locally hosted 404 server. -```bash -# If on linux run this command. Because this is run on a port below 1024, binary network permissions are needed. -sudo python3 -m http.server 80 - -# If on windows one of the following will work when run through Powershell or Command Prompt assuming python is installed -python3 -m http.server 80 -python http.server 80 -py -m http.server 80 -``` - ## Updating your server To update your server to the latest version navigate to your cloned directory ```bash diff --git a/dAuthServer/AuthServer.cpp b/dAuthServer/AuthServer.cpp index f5090495..262886d7 100644 --- a/dAuthServer/AuthServer.cpp +++ b/dAuthServer/AuthServer.cpp @@ -15,10 +15,13 @@ //RakNet includes: #include "RakNetDefines.h" +#include //Auth includes: #include "AuthPackets.h" -#include "dMessageIdentifiers.h" +#include "eConnectionType.h" +#include "eServerMessageType.h" +#include "eAuthMessageType.h" #include "Game.h" namespace Game { @@ -168,13 +171,15 @@ dLogger* SetupLogger() { } void HandlePacket(Packet* packet) { + if (packet->length < 4) return; + if (packet->data[0] == ID_USER_PACKET_ENUM) { - if (packet->data[1] == SERVER) { - if (packet->data[3] == MSG_SERVER_VERSION_CONFIRM) { + if (static_cast(packet->data[1]) == eConnectionType::SERVER) { + if (static_cast(packet->data[3]) == eServerMessageType::VERSION_CONFIRM) { AuthPackets::HandleHandshake(Game::server, packet); } - } else if (packet->data[1] == AUTH) { - if (packet->data[3] == MSG_AUTH_LOGIN_REQUEST) { + } else if (static_cast(packet->data[1]) == eConnectionType::AUTH) { + if (static_cast(packet->data[3]) == eAuthMessageType::LOGIN_REQUEST) { AuthPackets::HandleLoginRequest(Game::server, packet); } } diff --git a/dChatServer/ChatPacketHandler.cpp b/dChatServer/ChatPacketHandler.cpp index 592c3870..878cc71c 100644 --- a/dChatServer/ChatPacketHandler.cpp +++ b/dChatServer/ChatPacketHandler.cpp @@ -3,7 +3,6 @@ #include "Database.h" #include #include "PacketUtils.h" -#include "dMessageIdentifiers.h" #include "Game.h" #include "dServer.h" #include "GeneralUtils.h" @@ -12,15 +11,20 @@ #include "eAddFriendResponseType.h" #include "RakString.h" #include "dConfig.h" +#include "eObjectBits.h" +#include "eConnectionType.h" +#include "eChatMessageType.h" +#include "eChatInternalMessageType.h" +#include "eClientMessageType.h" +#include "eGameMessageType.h" extern PlayerContainer playerContainer; void ChatPacketHandler::HandleFriendlistRequest(Packet* packet) { //Get from the packet which player we want to do something with: - CINSTREAM; + CINSTREAM_SKIP_HEADER; LWOOBJID playerID = 0; inStream.Read(playerID); - inStream.Read(playerID); auto player = playerContainer.GetPlayerData(playerID); if (!player) return; @@ -45,8 +49,8 @@ void ChatPacketHandler::HandleFriendlistRequest(Packet* packet) { FriendData fd; fd.isFTP = false; // not a thing in DLU fd.friendID = res->getUInt(1); - GeneralUtils::SetBit(fd.friendID, static_cast(eObjectBits::OBJECT_BIT_PERSISTENT)); - GeneralUtils::SetBit(fd.friendID, static_cast(eObjectBits::OBJECT_BIT_CHARACTER)); + GeneralUtils::SetBit(fd.friendID, eObjectBits::PERSISTENT); + GeneralUtils::SetBit(fd.friendID, eObjectBits::CHARACTER); fd.isBestFriend = res->getInt(2) == 3; //0 = friends, 1 = left_requested, 2 = right_requested, 3 = both_accepted - are now bffs if (fd.isBestFriend) player->countOfBestFriends += 1; @@ -71,11 +75,11 @@ void ChatPacketHandler::HandleFriendlistRequest(Packet* packet) { //Now, we need to send the friendlist to the server they came from: CBITSTREAM; - PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_ROUTE_TO_PLAYER); + PacketUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER); bitStream.Write(playerID); //portion that will get routed: - PacketUtils::WriteHeader(bitStream, CLIENT, MSG_CLIENT_GET_FRIENDS_LIST_RESPONSE); + PacketUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::GET_FRIENDS_LIST_RESPONSE); bitStream.Write(0); bitStream.Write(1); //Length of packet -- just writing one as it doesn't matter, client skips it. bitStream.Write((uint16_t)friends.size()); @@ -94,10 +98,9 @@ void ChatPacketHandler::HandleFriendRequest(Packet* packet) { auto maxNumberOfBestFriendsAsString = Game::config->GetValue("max_number_of_best_friends"); // If this config option doesn't exist, default to 5 which is what live used. auto maxNumberOfBestFriends = maxNumberOfBestFriendsAsString != "" ? std::stoi(maxNumberOfBestFriendsAsString) : 5U; - CINSTREAM; + CINSTREAM_SKIP_HEADER; LWOOBJID requestorPlayerID; inStream.Read(requestorPlayerID); - inStream.Read(requestorPlayerID); uint32_t spacing{}; inStream.Read(spacing); std::string playerName = ""; @@ -178,10 +181,10 @@ void ChatPacketHandler::HandleFriendRequest(Packet* packet) { bestFriendStatus = oldBestFriendStatus; // Set the bits - GeneralUtils::SetBit(queryPlayerID, static_cast(eObjectBits::OBJECT_BIT_CHARACTER)); - GeneralUtils::SetBit(queryPlayerID, static_cast(eObjectBits::OBJECT_BIT_PERSISTENT)); - GeneralUtils::SetBit(queryFriendID, static_cast(eObjectBits::OBJECT_BIT_CHARACTER)); - GeneralUtils::SetBit(queryFriendID, static_cast(eObjectBits::OBJECT_BIT_PERSISTENT)); + GeneralUtils::SetBit(queryPlayerID, eObjectBits::CHARACTER); + GeneralUtils::SetBit(queryPlayerID, eObjectBits::PERSISTENT); + GeneralUtils::SetBit(queryFriendID, eObjectBits::CHARACTER); + GeneralUtils::SetBit(queryFriendID, eObjectBits::PERSISTENT); // Since this player can either be the friend of someone else or be friends with someone else // their column in the database determines what bit gets set. When the value hits 3, they @@ -242,10 +245,9 @@ void ChatPacketHandler::HandleFriendRequest(Packet* packet) { } void ChatPacketHandler::HandleFriendResponse(Packet* packet) { - CINSTREAM; + CINSTREAM_SKIP_HEADER; LWOOBJID playerID; inStream.Read(playerID); - inStream.Read(playerID); eAddFriendResponseCode clientResponseCode = static_cast(packet->data[0x14]); std::string friendName = PacketUtils::ReadString(0x15, packet, true); @@ -318,10 +320,9 @@ void ChatPacketHandler::HandleFriendResponse(Packet* packet) { } void ChatPacketHandler::HandleRemoveFriend(Packet* packet) { - CINSTREAM; + CINSTREAM_SKIP_HEADER; LWOOBJID playerID; inStream.Read(playerID); - inStream.Read(playerID); std::string friendName = PacketUtils::ReadString(0x14, packet, true); //we'll have to query the db here to find the user, since you can delete them while they're offline. @@ -336,8 +337,8 @@ void ChatPacketHandler::HandleRemoveFriend(Packet* packet) { } // Convert friendID to LWOOBJID - GeneralUtils::SetBit(friendID, static_cast(eObjectBits::OBJECT_BIT_PERSISTENT)); - GeneralUtils::SetBit(friendID, static_cast(eObjectBits::OBJECT_BIT_CHARACTER)); + GeneralUtils::SetBit(friendID, eObjectBits::PERSISTENT); + GeneralUtils::SetBit(friendID, eObjectBits::CHARACTER); std::unique_ptr deletestmt(Database::CreatePreppedStmt("DELETE FROM friends WHERE (player_id = ? AND friend_id = ?) OR (player_id = ? AND friend_id = ?) LIMIT 1;")); deletestmt->setUInt(1, static_cast(playerID)); @@ -376,10 +377,9 @@ void ChatPacketHandler::HandleRemoveFriend(Packet* packet) { } void ChatPacketHandler::HandleChatMessage(Packet* packet) { - CINSTREAM; + CINSTREAM_SKIP_HEADER; LWOOBJID playerID = LWOOBJID_EMPTY; inStream.Read(playerID); - inStream.Read(playerID); auto* sender = playerContainer.GetPlayerData(playerID); @@ -412,10 +412,10 @@ void ChatPacketHandler::HandleChatMessage(Packet* packet) { const auto otherName = std::string(otherMember->playerName.c_str()); CBITSTREAM; - PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_ROUTE_TO_PLAYER); + PacketUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER); bitStream.Write(otherMember->playerID); - PacketUtils::WriteHeader(bitStream, CHAT, MSG_CHAT_PRIVATE_CHAT_MESSAGE); + PacketUtils::WriteHeader(bitStream, eConnectionType::CHAT, eChatMessageType::PRIVATE_CHAT_MESSAGE); bitStream.Write(otherMember->playerID); bitStream.Write(8); bitStream.Write(69); @@ -451,10 +451,10 @@ void ChatPacketHandler::HandlePrivateChatMessage(Packet* packet) { //To the sender: { CBITSTREAM; - PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_ROUTE_TO_PLAYER); + PacketUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER); bitStream.Write(goonA->playerID); - PacketUtils::WriteHeader(bitStream, CHAT, MSG_CHAT_PRIVATE_CHAT_MESSAGE); + PacketUtils::WriteHeader(bitStream, eConnectionType::CHAT, eChatMessageType::PRIVATE_CHAT_MESSAGE); bitStream.Write(goonA->playerID); bitStream.Write(7); bitStream.Write(69); @@ -474,10 +474,10 @@ void ChatPacketHandler::HandlePrivateChatMessage(Packet* packet) { //To the receiver: { CBITSTREAM; - PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_ROUTE_TO_PLAYER); + PacketUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER); bitStream.Write(goonB->playerID); - PacketUtils::WriteHeader(bitStream, CHAT, MSG_CHAT_PRIVATE_CHAT_MESSAGE); + PacketUtils::WriteHeader(bitStream, eConnectionType::CHAT, eChatMessageType::PRIVATE_CHAT_MESSAGE); bitStream.Write(goonA->playerID); bitStream.Write(7); bitStream.Write(69); @@ -496,10 +496,9 @@ void ChatPacketHandler::HandlePrivateChatMessage(Packet* packet) { } void ChatPacketHandler::HandleTeamInvite(Packet* packet) { - CINSTREAM; + CINSTREAM_SKIP_HEADER; LWOOBJID playerID; inStream.Read(playerID); - inStream.Read(playerID); std::string invitedPlayer = PacketUtils::ReadString(0x14, packet, true); auto* player = playerContainer.GetPlayerData(playerID); @@ -537,10 +536,9 @@ void ChatPacketHandler::HandleTeamInvite(Packet* packet) { } void ChatPacketHandler::HandleTeamInviteResponse(Packet* packet) { - CINSTREAM; + CINSTREAM_SKIP_HEADER; LWOOBJID playerID = LWOOBJID_EMPTY; inStream.Read(playerID); - inStream.Read(playerID); uint32_t size = 0; inStream.Read(size); char declined = 0; @@ -571,10 +569,9 @@ void ChatPacketHandler::HandleTeamInviteResponse(Packet* packet) { } void ChatPacketHandler::HandleTeamLeave(Packet* packet) { - CINSTREAM; + CINSTREAM_SKIP_HEADER; LWOOBJID playerID = LWOOBJID_EMPTY; inStream.Read(playerID); - inStream.Read(playerID); uint32_t size = 0; inStream.Read(size); @@ -588,10 +585,9 @@ void ChatPacketHandler::HandleTeamLeave(Packet* packet) { } void ChatPacketHandler::HandleTeamKick(Packet* packet) { - CINSTREAM; + CINSTREAM_SKIP_HEADER; LWOOBJID playerID = LWOOBJID_EMPTY; inStream.Read(playerID); - inStream.Read(playerID); std::string kickedPlayer = PacketUtils::ReadString(0x14, packet, true); @@ -619,10 +615,9 @@ void ChatPacketHandler::HandleTeamKick(Packet* packet) { } void ChatPacketHandler::HandleTeamPromote(Packet* packet) { - CINSTREAM; + CINSTREAM_SKIP_HEADER; LWOOBJID playerID = LWOOBJID_EMPTY; inStream.Read(playerID); - inStream.Read(playerID); std::string promotedPlayer = PacketUtils::ReadString(0x14, packet, true); @@ -642,10 +637,9 @@ void ChatPacketHandler::HandleTeamPromote(Packet* packet) { } void ChatPacketHandler::HandleTeamLootOption(Packet* packet) { - CINSTREAM; + CINSTREAM_SKIP_HEADER; LWOOBJID playerID = LWOOBJID_EMPTY; inStream.Read(playerID); - inStream.Read(playerID); uint32_t size = 0; inStream.Read(size); @@ -666,10 +660,9 @@ void ChatPacketHandler::HandleTeamLootOption(Packet* packet) { } void ChatPacketHandler::HandleTeamStatusRequest(Packet* packet) { - CINSTREAM; + CINSTREAM_SKIP_HEADER; LWOOBJID playerID = LWOOBJID_EMPTY; inStream.Read(playerID); - inStream.Read(playerID); auto* team = playerContainer.GetTeam(playerID); auto* data = playerContainer.GetPlayerData(playerID); @@ -716,11 +709,11 @@ void ChatPacketHandler::HandleTeamStatusRequest(Packet* packet) { void ChatPacketHandler::SendTeamInvite(PlayerData* receiver, PlayerData* sender) { CBITSTREAM; - PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_ROUTE_TO_PLAYER); + PacketUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER); bitStream.Write(receiver->playerID); //portion that will get routed: - PacketUtils::WriteHeader(bitStream, CLIENT, MSG_CLIENT_TEAM_INVITE); + PacketUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::TEAM_INVITE); PacketUtils::WritePacketWString(sender->playerName.c_str(), 33, &bitStream); bitStream.Write(sender->playerID); @@ -731,14 +724,14 @@ void ChatPacketHandler::SendTeamInvite(PlayerData* receiver, PlayerData* sender) void ChatPacketHandler::SendTeamInviteConfirm(PlayerData* receiver, bool bLeaderIsFreeTrial, LWOOBJID i64LeaderID, LWOZONEID i64LeaderZoneID, uint8_t ucLootFlag, uint8_t ucNumOfOtherPlayers, uint8_t ucResponseCode, std::u16string wsLeaderName) { CBITSTREAM; - PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_ROUTE_TO_PLAYER); + PacketUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER); bitStream.Write(receiver->playerID); //portion that will get routed: CMSGHEADER; bitStream.Write(receiver->playerID); - bitStream.Write(GAME_MSG::GAME_MSG_TEAM_INVITE_CONFIRM); + bitStream.Write(eGameMessageType::TEAM_INVITE_CONFIRM); bitStream.Write(bLeaderIsFreeTrial); bitStream.Write(i64LeaderID); @@ -758,14 +751,14 @@ void ChatPacketHandler::SendTeamInviteConfirm(PlayerData* receiver, bool bLeader void ChatPacketHandler::SendTeamStatus(PlayerData* receiver, LWOOBJID i64LeaderID, LWOZONEID i64LeaderZoneID, uint8_t ucLootFlag, uint8_t ucNumOfOtherPlayers, std::u16string wsLeaderName) { CBITSTREAM; - PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_ROUTE_TO_PLAYER); + PacketUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER); bitStream.Write(receiver->playerID); //portion that will get routed: CMSGHEADER; bitStream.Write(receiver->playerID); - bitStream.Write(GAME_MSG::GAME_MSG_TEAM_GET_STATUS_RESPONSE); + bitStream.Write(eGameMessageType::TEAM_GET_STATUS_RESPONSE); bitStream.Write(i64LeaderID); bitStream.Write(i64LeaderZoneID); @@ -783,14 +776,14 @@ void ChatPacketHandler::SendTeamStatus(PlayerData* receiver, LWOOBJID i64LeaderI void ChatPacketHandler::SendTeamSetLeader(PlayerData* receiver, LWOOBJID i64PlayerID) { CBITSTREAM; - PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_ROUTE_TO_PLAYER); + PacketUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER); bitStream.Write(receiver->playerID); //portion that will get routed: CMSGHEADER; bitStream.Write(receiver->playerID); - bitStream.Write(GAME_MSG::GAME_MSG_TEAM_SET_LEADER); + bitStream.Write(eGameMessageType::TEAM_SET_LEADER); bitStream.Write(i64PlayerID); @@ -800,14 +793,14 @@ void ChatPacketHandler::SendTeamSetLeader(PlayerData* receiver, LWOOBJID i64Play void ChatPacketHandler::SendTeamAddPlayer(PlayerData* receiver, bool bIsFreeTrial, bool bLocal, bool bNoLootOnDeath, LWOOBJID i64PlayerID, std::u16string wsPlayerName, LWOZONEID zoneID) { CBITSTREAM; - PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_ROUTE_TO_PLAYER); + PacketUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER); bitStream.Write(receiver->playerID); //portion that will get routed: CMSGHEADER; bitStream.Write(receiver->playerID); - bitStream.Write(GAME_MSG::GAME_MSG_TEAM_ADD_PLAYER); + bitStream.Write(eGameMessageType::TEAM_ADD_PLAYER); bitStream.Write(bIsFreeTrial); bitStream.Write(bLocal); @@ -829,14 +822,14 @@ void ChatPacketHandler::SendTeamAddPlayer(PlayerData* receiver, bool bIsFreeTria void ChatPacketHandler::SendTeamRemovePlayer(PlayerData* receiver, bool bDisband, bool bIsKicked, bool bIsLeaving, bool bLocal, LWOOBJID i64LeaderID, LWOOBJID i64PlayerID, std::u16string wsPlayerName) { CBITSTREAM; - PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_ROUTE_TO_PLAYER); + PacketUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER); bitStream.Write(receiver->playerID); //portion that will get routed: CMSGHEADER; bitStream.Write(receiver->playerID); - bitStream.Write(GAME_MSG::GAME_MSG_TEAM_REMOVE_PLAYER); + bitStream.Write(eGameMessageType::TEAM_REMOVE_PLAYER); bitStream.Write(bDisband); bitStream.Write(bIsKicked); @@ -855,14 +848,14 @@ void ChatPacketHandler::SendTeamRemovePlayer(PlayerData* receiver, bool bDisband void ChatPacketHandler::SendTeamSetOffWorldFlag(PlayerData* receiver, LWOOBJID i64PlayerID, LWOZONEID zoneID) { CBITSTREAM; - PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_ROUTE_TO_PLAYER); + PacketUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER); bitStream.Write(receiver->playerID); //portion that will get routed: CMSGHEADER; bitStream.Write(receiver->playerID); - bitStream.Write(GAME_MSG::GAME_MSG_TEAM_SET_OFF_WORLD_FLAG); + bitStream.Write(eGameMessageType::TEAM_SET_OFF_WORLD_FLAG); bitStream.Write(i64PlayerID); if (receiver->zoneID.GetCloneID() == zoneID.GetCloneID()) { @@ -889,11 +882,11 @@ void ChatPacketHandler::SendFriendUpdate(PlayerData* friendData, PlayerData* pla [bool] - is FTP*/ CBITSTREAM; - PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_ROUTE_TO_PLAYER); + PacketUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER); bitStream.Write(friendData->playerID); //portion that will get routed: - PacketUtils::WriteHeader(bitStream, CLIENT, MSG_CLIENT_UPDATE_FRIEND_NOTIFY); + PacketUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::UPDATE_FRIEND_NOTIFY); bitStream.Write(notifyType); std::string playerName = playerData->playerName.c_str(); @@ -928,11 +921,11 @@ void ChatPacketHandler::SendFriendRequest(PlayerData* receiver, PlayerData* send } CBITSTREAM; - PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_ROUTE_TO_PLAYER); + PacketUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER); bitStream.Write(receiver->playerID); //portion that will get routed: - PacketUtils::WriteHeader(bitStream, CLIENT, MSG_CLIENT_ADD_FRIEND_REQUEST); + PacketUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::ADD_FRIEND_REQUEST); PacketUtils::WritePacketWString(sender->playerName.c_str(), 33, &bitStream); bitStream.Write(0); // This is a BFF flag however this is unused in live and does not have an implementation client side. @@ -944,11 +937,11 @@ void ChatPacketHandler::SendFriendResponse(PlayerData* receiver, PlayerData* sen if (!receiver || !sender) return; CBITSTREAM; - PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_ROUTE_TO_PLAYER); + PacketUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER); bitStream.Write(receiver->playerID); // Portion that will get routed: - PacketUtils::WriteHeader(bitStream, CLIENT, MSG_CLIENT_ADD_FRIEND_RESPONSE); + PacketUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::ADD_FRIEND_RESPONSE); bitStream.Write(responseCode); // For all requests besides accepted, write a flag that says whether or not we are already best friends with the receiver. bitStream.Write(responseCode != eAddFriendResponseType::ACCEPTED ? isBestFriendsAlready : sender->sysAddr != UNASSIGNED_SYSTEM_ADDRESS); @@ -969,11 +962,11 @@ void ChatPacketHandler::SendRemoveFriend(PlayerData* receiver, std::string& pers if (!receiver) return; CBITSTREAM; - PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_ROUTE_TO_PLAYER); + PacketUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ROUTE_TO_PLAYER); bitStream.Write(receiver->playerID); //portion that will get routed: - PacketUtils::WriteHeader(bitStream, CLIENT, MSG_CLIENT_REMOVE_FRIEND_RESPONSE); + PacketUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::REMOVE_FRIEND_RESPONSE); bitStream.Write(isSuccessful); //isOnline PacketUtils::WritePacketWString(personToRemove, 33, &bitStream); diff --git a/dChatServer/ChatServer.cpp b/dChatServer/ChatServer.cpp index a75c4d51..b9fb8556 100644 --- a/dChatServer/ChatServer.cpp +++ b/dChatServer/ChatServer.cpp @@ -9,19 +9,23 @@ #include "dLogger.h" #include "Database.h" #include "dConfig.h" -#include "dMessageIdentifiers.h" #include "dChatFilter.h" #include "Diagnostics.h" #include "AssetManager.h" #include "BinaryPathFinder.h" - +#include "eConnectionType.h" #include "PlayerContainer.h" #include "ChatPacketHandler.h" +#include "eChatMessageType.h" +#include "eChatInternalMessageType.h" +#include "eWorldMessageType.h" #include "Game.h" //RakNet includes: #include "RakNetDefines.h" +#include + namespace Game { dLogger* logger = nullptr; dServer* server = nullptr; @@ -68,7 +72,7 @@ int main(int argc, char** argv) { Game::assetManager = new AssetManager(clientPath); } catch (std::runtime_error& ex) { Game::logger->Log("ChatServer", "Got an error while setting up assets: %s", ex.what()); - + return EXIT_FAILURE; } @@ -199,25 +203,27 @@ void HandlePacket(Packet* packet) { Game::logger->Log("ChatServer", "A server is connecting, awaiting user list."); } - if (packet->data[1] == CHAT_INTERNAL) { - switch (packet->data[3]) { - case MSG_CHAT_INTERNAL_PLAYER_ADDED_NOTIFICATION: + if (packet->length < 4) return; // Nothing left to process. Need 4 bytes to continue. + + if (static_cast(packet->data[1]) == eConnectionType::CHAT_INTERNAL) { + switch (static_cast(packet->data[3])) { + case eChatInternalMessageType::PLAYER_ADDED_NOTIFICATION: playerContainer.InsertPlayer(packet); break; - case MSG_CHAT_INTERNAL_PLAYER_REMOVED_NOTIFICATION: + case eChatInternalMessageType::PLAYER_REMOVED_NOTIFICATION: playerContainer.RemovePlayer(packet); break; - case MSG_CHAT_INTERNAL_MUTE_UPDATE: + case eChatInternalMessageType::MUTE_UPDATE: playerContainer.MuteUpdate(packet); break; - case MSG_CHAT_INTERNAL_CREATE_TEAM: + case eChatInternalMessageType::CREATE_TEAM: playerContainer.CreateTeamServer(packet); break; - case MSG_CHAT_INTERNAL_ANNOUNCEMENT: { + case eChatInternalMessageType::ANNOUNCEMENT: { //we just forward this packet to every connected server CINSTREAM; Game::server->Send(&inStream, packet->systemAddress, true); //send to everyone except origin @@ -229,67 +235,67 @@ void HandlePacket(Packet* packet) { } } - if (packet->data[1] == CHAT) { - switch (packet->data[3]) { - case MSG_CHAT_GET_FRIENDS_LIST: + if (static_cast(packet->data[1]) == eConnectionType::CHAT) { + switch (static_cast(packet->data[3])) { + case eChatMessageType::GET_FRIENDS_LIST: ChatPacketHandler::HandleFriendlistRequest(packet); break; - case MSG_CHAT_GET_IGNORE_LIST: + case eChatMessageType::GET_IGNORE_LIST: Game::logger->Log("ChatServer", "Asked for ignore list, but is unimplemented right now."); break; - case MSG_CHAT_TEAM_GET_STATUS: + case eChatMessageType::TEAM_GET_STATUS: ChatPacketHandler::HandleTeamStatusRequest(packet); break; - case MSG_CHAT_ADD_FRIEND_REQUEST: + case eChatMessageType::ADD_FRIEND_REQUEST: //this involves someone sending the initial request, the response is below, response as in from the other player. //We basically just check to see if this player is online or not and route the packet. ChatPacketHandler::HandleFriendRequest(packet); break; - case MSG_CHAT_ADD_FRIEND_RESPONSE: + case eChatMessageType::ADD_FRIEND_RESPONSE: //This isn't the response a server sent, rather it is a player's response to a received request. //Here, we'll actually have to add them to eachother's friend lists depending on the response code. ChatPacketHandler::HandleFriendResponse(packet); break; - case MSG_CHAT_REMOVE_FRIEND: + case eChatMessageType::REMOVE_FRIEND: ChatPacketHandler::HandleRemoveFriend(packet); break; - case MSG_CHAT_GENERAL_CHAT_MESSAGE: + case eChatMessageType::GENERAL_CHAT_MESSAGE: ChatPacketHandler::HandleChatMessage(packet); break; - case MSG_CHAT_PRIVATE_CHAT_MESSAGE: + case eChatMessageType::PRIVATE_CHAT_MESSAGE: //This message is supposed to be echo'd to both the sender and the receiver //BUT: they have to have different responseCodes, so we'll do some of the ol hacky wacky to fix that right up. ChatPacketHandler::HandlePrivateChatMessage(packet); break; - case MSG_CHAT_TEAM_INVITE: + case eChatMessageType::TEAM_INVITE: ChatPacketHandler::HandleTeamInvite(packet); break; - case MSG_CHAT_TEAM_INVITE_RESPONSE: + case eChatMessageType::TEAM_INVITE_RESPONSE: ChatPacketHandler::HandleTeamInviteResponse(packet); break; - case MSG_CHAT_TEAM_LEAVE: + case eChatMessageType::TEAM_LEAVE: ChatPacketHandler::HandleTeamLeave(packet); break; - case MSG_CHAT_TEAM_SET_LEADER: + case eChatMessageType::TEAM_SET_LEADER: ChatPacketHandler::HandleTeamPromote(packet); break; - case MSG_CHAT_TEAM_KICK: + case eChatMessageType::TEAM_KICK: ChatPacketHandler::HandleTeamKick(packet); break; - case MSG_CHAT_TEAM_SET_LOOT: + case eChatMessageType::TEAM_SET_LOOT: ChatPacketHandler::HandleTeamLootOption(packet); break; @@ -298,9 +304,9 @@ void HandlePacket(Packet* packet) { } } - if (packet->data[1] == WORLD) { - switch (packet->data[3]) { - case MSG_WORLD_CLIENT_ROUTE_PACKET: { + if (static_cast(packet->data[1]) == eConnectionType::WORLD) { + switch (static_cast(packet->data[3])) { + case eWorldMessageType::ROUTE_PACKET: { Game::logger->Log("ChatServer", "Routing packet from world"); break; } diff --git a/dChatServer/PlayerContainer.cpp b/dChatServer/PlayerContainer.cpp index 6bf3ccd1..689ffd77 100644 --- a/dChatServer/PlayerContainer.cpp +++ b/dChatServer/PlayerContainer.cpp @@ -6,9 +6,10 @@ #include "dLogger.h" #include "ChatPacketHandler.h" #include "GeneralUtils.h" -#include "dMessageIdentifiers.h" #include "PacketUtils.h" #include "Database.h" +#include "eConnectionType.h" +#include "eChatInternalMessageType.h" PlayerContainer::PlayerContainer() { } @@ -18,9 +19,8 @@ PlayerContainer::~PlayerContainer() { } void PlayerContainer::InsertPlayer(Packet* packet) { - CINSTREAM; + CINSTREAM_SKIP_HEADER; PlayerData* data = new PlayerData(); - inStream.SetReadOffset(inStream.GetReadOffset() + 64); inStream.Read(data->playerID); uint32_t len; @@ -51,9 +51,8 @@ void PlayerContainer::InsertPlayer(Packet* packet) { } void PlayerContainer::RemovePlayer(Packet* packet) { - CINSTREAM; + CINSTREAM_SKIP_HEADER; LWOOBJID playerID; - inStream.Read(playerID); //skip header inStream.Read(playerID); //Before they get kicked, we need to also send a message to their friends saying that they disconnected. @@ -96,9 +95,8 @@ void PlayerContainer::RemovePlayer(Packet* packet) { } void PlayerContainer::MuteUpdate(Packet* packet) { - CINSTREAM; + CINSTREAM_SKIP_HEADER; LWOOBJID playerID; - inStream.Read(playerID); //skip header inStream.Read(playerID); time_t expire = 0; inStream.Read(expire); @@ -117,9 +115,8 @@ void PlayerContainer::MuteUpdate(Packet* packet) { } void PlayerContainer::CreateTeamServer(Packet* packet) { - CINSTREAM; + CINSTREAM_SKIP_HEADER; LWOOBJID playerID; - inStream.Read(playerID); //skip header inStream.Read(playerID); size_t membersSize = 0; inStream.Read(membersSize); @@ -149,7 +146,7 @@ void PlayerContainer::CreateTeamServer(Packet* packet) { void PlayerContainer::BroadcastMuteUpdate(LWOOBJID player, time_t time) { CBITSTREAM; - PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_MUTE_UPDATE); + PacketUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::MUTE_UPDATE); bitStream.Write(player); bitStream.Write(time); @@ -348,7 +345,7 @@ void PlayerContainer::TeamStatusUpdate(TeamData* team) { void PlayerContainer::UpdateTeamsOnWorld(TeamData* team, bool deleteTeam) { CBITSTREAM; - PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_TEAM_UPDATE); + PacketUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::TEAM_UPDATE); bitStream.Write(team->teamID); bitStream.Write(deleteTeam); diff --git a/dCommon/AMFDeserialize.cpp b/dCommon/AMFDeserialize.cpp index df4a7cb6..9eee1f12 100644 --- a/dCommon/AMFDeserialize.cpp +++ b/dCommon/AMFDeserialize.cpp @@ -1,77 +1,81 @@ #include "AMFDeserialize.h" -#include "AMFFormat.h" +#include + +#include "Amf3.h" /** * AMF3 Reference document https://rtmp.veriskope.com/pdf/amf3-file-format-spec.pdf * AMF3 Deserializer written by EmosewaMC */ -AMFValue* AMFDeserialize::Read(RakNet::BitStream* inStream) { +AMFBaseValue* AMFDeserialize::Read(RakNet::BitStream* inStream) { if (!inStream) return nullptr; - AMFValue* returnValue = nullptr; + AMFBaseValue* returnValue = nullptr; // Read in the value type from the bitStream - int8_t marker; - inStream->Read(marker); + uint8_t i; + inStream->Read(i); + if (i > static_cast(eAmf::Dictionary)) return nullptr; + eAmf marker = static_cast(i); // Based on the typing, create the value associated with that and return the base value class switch (marker) { - case AMFValueType::AMFUndefined: { - returnValue = new AMFUndefinedValue(); + case eAmf::Undefined: { + returnValue = new AMFBaseValue(); break; } - case AMFValueType::AMFNull: { + case eAmf::Null: { returnValue = new AMFNullValue(); break; } - case AMFValueType::AMFFalse: { - returnValue = new AMFFalseValue(); + case eAmf::False: { + returnValue = new AMFBoolValue(false); break; } - case AMFValueType::AMFTrue: { - returnValue = new AMFTrueValue(); + case eAmf::True: { + returnValue = new AMFBoolValue(true); break; } - case AMFValueType::AMFInteger: { + case eAmf::Integer: { returnValue = ReadAmfInteger(inStream); break; } - case AMFValueType::AMFDouble: { + case eAmf::Double: { returnValue = ReadAmfDouble(inStream); break; } - case AMFValueType::AMFString: { + case eAmf::String: { returnValue = ReadAmfString(inStream); break; } - case AMFValueType::AMFArray: { + case eAmf::Array: { returnValue = ReadAmfArray(inStream); break; } - // TODO We do not need these values, but if someone wants to implement them - // then please do so and add the corresponding unit tests. - case AMFValueType::AMFXMLDoc: - case AMFValueType::AMFDate: - case AMFValueType::AMFObject: - case AMFValueType::AMFXML: - case AMFValueType::AMFByteArray: - case AMFValueType::AMFVectorInt: - case AMFValueType::AMFVectorUInt: - case AMFValueType::AMFVectorDouble: - case AMFValueType::AMFVectorObject: - case AMFValueType::AMFDictionary: { - throw static_cast(marker); + // These values are unimplemented in the live client and will remain unimplemented + // unless someone modifies the client to allow serializing of these values. + case eAmf::XMLDoc: + case eAmf::Date: + case eAmf::Object: + case eAmf::XML: + case eAmf::ByteArray: + case eAmf::VectorInt: + case eAmf::VectorUInt: + case eAmf::VectorDouble: + case eAmf::VectorObject: + case eAmf::Dictionary: { + throw marker; break; } default: - throw static_cast(marker); + throw std::invalid_argument("Invalid AMF3 marker" + std::to_string(static_cast(marker))); break; } return returnValue; @@ -99,7 +103,7 @@ uint32_t AMFDeserialize::ReadU29(RakNet::BitStream* inStream) { return actualNumber; } -std::string AMFDeserialize::ReadString(RakNet::BitStream* inStream) { +const std::string AMFDeserialize::ReadString(RakNet::BitStream* inStream) { auto length = ReadU29(inStream); // Check if this is a reference bool isReference = length % 2 == 1; @@ -113,48 +117,39 @@ std::string AMFDeserialize::ReadString(RakNet::BitStream* inStream) { return value; } else { // Length is a reference to a previous index - use that as the read in value - return accessedElements[length]; + return accessedElements.at(length); } } -AMFValue* AMFDeserialize::ReadAmfDouble(RakNet::BitStream* inStream) { - auto doubleValue = new AMFDoubleValue(); +AMFBaseValue* AMFDeserialize::ReadAmfDouble(RakNet::BitStream* inStream) { double value; inStream->Read(value); - doubleValue->SetDoubleValue(value); - return doubleValue; + return new AMFDoubleValue(value); } -AMFValue* AMFDeserialize::ReadAmfArray(RakNet::BitStream* inStream) { +AMFBaseValue* AMFDeserialize::ReadAmfArray(RakNet::BitStream* inStream) { auto arrayValue = new AMFArrayValue(); // Read size of dense array auto sizeOfDenseArray = (ReadU29(inStream) >> 1); - - // Then read Key'd portion + // Then read associative portion while (true) { auto key = ReadString(inStream); - // No more values when we encounter an empty string + // No more associative values when we encounter an empty string key if (key.size() == 0) break; - arrayValue->InsertValue(key, Read(inStream)); + arrayValue->Insert(key, Read(inStream)); } - // Finally read dense portion for (uint32_t i = 0; i < sizeOfDenseArray; i++) { - arrayValue->PushBackValue(Read(inStream)); + arrayValue->Insert(i, Read(inStream)); } - return arrayValue; } -AMFValue* AMFDeserialize::ReadAmfString(RakNet::BitStream* inStream) { - auto stringValue = new AMFStringValue(); - stringValue->SetStringValue(ReadString(inStream)); - return stringValue; +AMFBaseValue* AMFDeserialize::ReadAmfString(RakNet::BitStream* inStream) { + return new AMFStringValue(ReadString(inStream)); } -AMFValue* AMFDeserialize::ReadAmfInteger(RakNet::BitStream* inStream) { - auto integerValue = new AMFIntegerValue(); - integerValue->SetIntegerValue(ReadU29(inStream)); - return integerValue; +AMFBaseValue* AMFDeserialize::ReadAmfInteger(RakNet::BitStream* inStream) { + return new AMFIntValue(ReadU29(inStream)); } diff --git a/dCommon/AMFDeserialize.h b/dCommon/AMFDeserialize.h index a49cdcd2..5e2729eb 100644 --- a/dCommon/AMFDeserialize.h +++ b/dCommon/AMFDeserialize.h @@ -5,7 +5,8 @@ #include #include -class AMFValue; +class AMFBaseValue; + class AMFDeserialize { public: /** @@ -14,7 +15,7 @@ public: * @param inStream inStream to read value from. * @return Returns an AMFValue with all the information from the bitStream in it. */ - AMFValue* Read(RakNet::BitStream* inStream); + AMFBaseValue* Read(RakNet::BitStream* inStream); private: /** * @brief Private method to read a U29 integer from a bitstream @@ -30,7 +31,7 @@ private: * @param inStream bitStream to read data from * @return The read string */ - std::string ReadString(RakNet::BitStream* inStream); + const std::string ReadString(RakNet::BitStream* inStream); /** * @brief Read an AMFDouble value from a bitStream @@ -38,7 +39,7 @@ private: * @param inStream bitStream to read data from * @return Double value represented as an AMFValue */ - AMFValue* ReadAmfDouble(RakNet::BitStream* inStream); + AMFBaseValue* ReadAmfDouble(RakNet::BitStream* inStream); /** * @brief Read an AMFArray from a bitStream @@ -46,7 +47,7 @@ private: * @param inStream bitStream to read data from * @return Array value represented as an AMFValue */ - AMFValue* ReadAmfArray(RakNet::BitStream* inStream); + AMFBaseValue* ReadAmfArray(RakNet::BitStream* inStream); /** * @brief Read an AMFString from a bitStream @@ -54,7 +55,7 @@ private: * @param inStream bitStream to read data from * @return String value represented as an AMFValue */ - AMFValue* ReadAmfString(RakNet::BitStream* inStream); + AMFBaseValue* ReadAmfString(RakNet::BitStream* inStream); /** * @brief Read an AMFInteger from a bitStream @@ -62,7 +63,7 @@ private: * @param inStream bitStream to read data from * @return Integer value represented as an AMFValue */ - AMFValue* ReadAmfInteger(RakNet::BitStream* inStream); + AMFBaseValue* ReadAmfInteger(RakNet::BitStream* inStream); /** * List of strings read so far saved to be read by reference. diff --git a/dCommon/AMFFormat.cpp b/dCommon/AMFFormat.cpp deleted file mode 100644 index 4407b29c..00000000 --- a/dCommon/AMFFormat.cpp +++ /dev/null @@ -1,156 +0,0 @@ -#include "AMFFormat.h" - -// AMFInteger -void AMFIntegerValue::SetIntegerValue(uint32_t value) { - this->value = value; -} - -uint32_t AMFIntegerValue::GetIntegerValue() { - return this->value; -} - -// AMFDouble -void AMFDoubleValue::SetDoubleValue(double value) { - this->value = value; -} - -double AMFDoubleValue::GetDoubleValue() { - return this->value; -} - -// AMFString -void AMFStringValue::SetStringValue(const std::string& value) { - this->value = value; -} - -std::string AMFStringValue::GetStringValue() { - return this->value; -} - -// AMFXMLDoc -void AMFXMLDocValue::SetXMLDocValue(const std::string& value) { - this->xmlData = value; -} - -std::string AMFXMLDocValue::GetXMLDocValue() { - return this->xmlData; -} - -// AMFDate -void AMFDateValue::SetDateValue(uint64_t value) { - this->millisecondTimestamp = value; -} - -uint64_t AMFDateValue::GetDateValue() { - return this->millisecondTimestamp; -} - -// AMFArray Insert Value -void AMFArrayValue::InsertValue(const std::string& key, AMFValue* value) { - this->associative.insert(std::make_pair(key, value)); -} - -// AMFArray Remove Value -void AMFArrayValue::RemoveValue(const std::string& key) { - _AMFArrayMap_::iterator it = this->associative.find(key); - if (it != this->associative.end()) { - this->associative.erase(it); - } -} - -// AMFArray Get Associative Iterator Begin -_AMFArrayMap_::iterator AMFArrayValue::GetAssociativeIteratorValueBegin() { - return this->associative.begin(); -} - -// AMFArray Get Associative Iterator End -_AMFArrayMap_::iterator AMFArrayValue::GetAssociativeIteratorValueEnd() { - return this->associative.end(); -} - -// AMFArray Push Back Value -void AMFArrayValue::PushBackValue(AMFValue* value) { - this->dense.push_back(value); -} - -// AMFArray Pop Back Value -void AMFArrayValue::PopBackValue() { - this->dense.pop_back(); -} - -// AMFArray Get Dense List Size -uint32_t AMFArrayValue::GetDenseValueSize() { - return (uint32_t)this->dense.size(); -} - -// AMFArray Get Dense Iterator Begin -_AMFArrayList_::iterator AMFArrayValue::GetDenseIteratorBegin() { - return this->dense.begin(); -} - -// AMFArray Get Dense Iterator End -_AMFArrayList_::iterator AMFArrayValue::GetDenseIteratorEnd() { - return this->dense.end(); -} - -AMFArrayValue::~AMFArrayValue() { - for (auto valueToDelete : GetDenseArray()) { - if (valueToDelete) delete valueToDelete; - } - for (auto valueToDelete : GetAssociativeMap()) { - if (valueToDelete.second) delete valueToDelete.second; - } -} - -// AMFObject Constructor -AMFObjectValue::AMFObjectValue(std::vector> traits) { - this->traits.reserve(traits.size()); - std::vector>::iterator it = traits.begin(); - while (it != traits.end()) { - this->traits.insert(std::make_pair(it->first, std::make_pair(it->second, new AMFNullValue()))); - it++; - } -} - -// AMFObject Set Value -void AMFObjectValue::SetTraitValue(const std::string& trait, AMFValue* value) { - if (value) { - _AMFObjectTraits_::iterator it = this->traits.find(trait); - if (it != this->traits.end()) { - if (it->second.first == value->GetValueType()) { - it->second.second = value; - } - } - } -} - -// AMFObject Get Value -AMFValue* AMFObjectValue::GetTraitValue(const std::string& trait) { - _AMFObjectTraits_::iterator it = this->traits.find(trait); - if (it != this->traits.end()) { - return it->second.second; - } - - return nullptr; -} - -// AMFObject Get Trait Iterator Begin -_AMFObjectTraits_::iterator AMFObjectValue::GetTraitsIteratorBegin() { - return this->traits.begin(); -} - -// AMFObject Get Trait Iterator End -_AMFObjectTraits_::iterator AMFObjectValue::GetTraitsIteratorEnd() { - return this->traits.end(); -} - -// AMFObject Get Trait Size -uint32_t AMFObjectValue::GetTraitArrayCount() { - return (uint32_t)this->traits.size(); -} - -AMFObjectValue::~AMFObjectValue() { - for (auto valueToDelete = GetTraitsIteratorBegin(); valueToDelete != GetTraitsIteratorEnd(); valueToDelete++) { - if (valueToDelete->second.second) delete valueToDelete->second.second; - } -} diff --git a/dCommon/AMFFormat.h b/dCommon/AMFFormat.h deleted file mode 100644 index 6e479ef6..00000000 --- a/dCommon/AMFFormat.h +++ /dev/null @@ -1,413 +0,0 @@ -#pragma once - -// Custom Classes -#include "dCommonVars.h" - -// C++ -#include -#include - -/*! - \file AMFFormat.hpp - \brief A class for managing AMF values - */ - -class AMFValue; // Forward declaration - -// Definitions -#define _AMFArrayMap_ std::unordered_map -#define _AMFArrayList_ std::vector - -#define _AMFObjectTraits_ std::unordered_map> -#define _AMFObjectDynamicTraits_ std::unordered_map - -//! An enum for each AMF value type -enum AMFValueType : unsigned char { - AMFUndefined = 0x00, //!< An undefined AMF Value - AMFNull = 0x01, //!< A null AMF value - AMFFalse = 0x02, //!< A false AMF value - AMFTrue = 0x03, //!< A true AMF value - AMFInteger = 0x04, //!< An integer AMF value - AMFDouble = 0x05, //!< A double AMF value - AMFString = 0x06, //!< A string AMF value - AMFXMLDoc = 0x07, //!< An XML Doc AMF value - AMFDate = 0x08, //!< A date AMF value - AMFArray = 0x09, //!< An array AMF value - AMFObject = 0x0A, //!< An object AMF value - AMFXML = 0x0B, //!< An XML AMF value - AMFByteArray = 0x0C, //!< A byte array AMF value - AMFVectorInt = 0x0D, //!< An integer vector AMF value - AMFVectorUInt = 0x0E, //!< An unsigned integer AMF value - AMFVectorDouble = 0x0F, //!< A double vector AMF value - AMFVectorObject = 0x10, //!< An object vector AMF value - AMFDictionary = 0x11 //!< A dictionary AMF value -}; - -//! An enum for the object value types -enum AMFObjectValueType : unsigned char { - AMFObjectAnonymous = 0x01, - AMFObjectTyped = 0x02, - AMFObjectDynamic = 0x03, - AMFObjectExternalizable = 0x04 -}; - -//! The base AMF value class -class AMFValue { -public: - //! Returns the AMF value type - /*! - \return The AMF value type - */ - virtual AMFValueType GetValueType() = 0; - virtual ~AMFValue() {}; -}; - -//! A typedef for a pointer to an AMF value -typedef AMFValue* NDGFxValue; - - -// The various AMF value types - -//! The undefined value AMF type -class AMFUndefinedValue : public AMFValue { -private: - //! Returns the AMF value type - /*! - \return The AMF value type - */ - AMFValueType GetValueType() { return ValueType; } -public: - static const AMFValueType ValueType = AMFUndefined; -}; - -//! The null value AMF type -class AMFNullValue : public AMFValue { -private: - //! Returns the AMF value type - /*! - \return The AMF value type - */ - AMFValueType GetValueType() { return ValueType; } -public: - static const AMFValueType ValueType = AMFNull; -}; - -//! The false value AMF type -class AMFFalseValue : public AMFValue { -private: - //! Returns the AMF value type - /*! - \return The AMF value type - */ - AMFValueType GetValueType() { return ValueType; } -public: - static const AMFValueType ValueType = AMFFalse; -}; - -//! The true value AMF type -class AMFTrueValue : public AMFValue { -private: - //! Returns the AMF value type - /*! - \return The AMF value type - */ - AMFValueType GetValueType() { return ValueType; } -public: - static const AMFValueType ValueType = AMFTrue; -}; - -//! The integer value AMF type -class AMFIntegerValue : public AMFValue { -private: - uint32_t value; //!< The value of the AMF type - - //! Returns the AMF value type - /*! - \return The AMF value type - */ - AMFValueType GetValueType() { return ValueType; } - -public: - static const AMFValueType ValueType = AMFInteger; - //! Sets the integer value - /*! - \param value The value to set - */ - void SetIntegerValue(uint32_t value); - - //! Gets the integer value - /*! - \return The integer value - */ - uint32_t GetIntegerValue(); -}; - -//! The double value AMF type -class AMFDoubleValue : public AMFValue { -private: - double value; //!< The value of the AMF type - - //! Returns the AMF value type - /*! - \return The AMF value type - */ - AMFValueType GetValueType() { return ValueType; } - -public: - static const AMFValueType ValueType = AMFDouble; - //! Sets the double value - /*! - \param value The value to set to - */ - void SetDoubleValue(double value); - - //! Gets the double value - /*! - \return The double value - */ - double GetDoubleValue(); -}; - -//! The string value AMF type -class AMFStringValue : public AMFValue { -private: - std::string value; //!< The value of the AMF type - - //! Returns the AMF value type - /*! - \return The AMF value type - */ - AMFValueType GetValueType() { return ValueType; } - -public: - static const AMFValueType ValueType = AMFString; - //! Sets the string value - /*! - \param value The string value to set to - */ - void SetStringValue(const std::string& value); - - //! Gets the string value - /*! - \return The string value - */ - std::string GetStringValue(); -}; - -//! The XML doc value AMF type -class AMFXMLDocValue : public AMFValue { -private: - std::string xmlData; //!< The value of the AMF type - - //! Returns the AMF value type - /*! - \return The AMF value type - */ - AMFValueType GetValueType() { return ValueType; } - -public: - static const AMFValueType ValueType = AMFXMLDoc; - //! Sets the XML Doc value - /*! - \param value The value to set to - */ - void SetXMLDocValue(const std::string& value); - - //! Gets the XML Doc value - /*! - \return The XML Doc value - */ - std::string GetXMLDocValue(); -}; - -//! The date value AMF type -class AMFDateValue : public AMFValue { -private: - uint64_t millisecondTimestamp; //!< The time in milliseconds since the ephoch - - //! Returns the AMF value type - /*! - \return The AMF value type - */ - AMFValueType GetValueType() { return ValueType; } - -public: - static const AMFValueType ValueType = AMFDate; - //! Sets the date time - /*! - \param value The value to set to - */ - void SetDateValue(uint64_t value); - - //! Gets the date value - /*! - \return The date value in milliseconds since the epoch - */ - uint64_t GetDateValue(); -}; - -//! The array value AMF type -// This object will manage it's own memory map and list. Do not delete its values. -class AMFArrayValue : public AMFValue { -private: - _AMFArrayMap_ associative; //!< The array map (associative part) - _AMFArrayList_ dense; //!< The array list (dense part) - - //! Returns the AMF value type - /*! - \return The AMF value type - */ - AMFValueType GetValueType() override { return ValueType; } - -public: - static const AMFValueType ValueType = AMFArray; - - ~AMFArrayValue() override; - //! Inserts an item into the array map for a specific key - /*! - \param key The key to set - \param value The value to add - */ - void InsertValue(const std::string& key, AMFValue* value); - - //! Removes an item for a specific key - /*! - \param key The key to remove - */ - void RemoveValue(const std::string& key); - - //! Finds an AMF value - /*! - \return The AMF value if found, nullptr otherwise - */ - template - T* FindValue(const std::string& key) const { - _AMFArrayMap_::const_iterator it = this->associative.find(key); - if (it != this->associative.end() && T::ValueType == it->second->GetValueType()) { - return dynamic_cast(it->second); - } - - return nullptr; - }; - - //! Returns where the associative iterator begins - /*! - \return Where the array map iterator begins - */ - _AMFArrayMap_::iterator GetAssociativeIteratorValueBegin(); - - //! Returns where the associative iterator ends - /*! - \return Where the array map iterator ends - */ - _AMFArrayMap_::iterator GetAssociativeIteratorValueEnd(); - - //! Pushes back a value into the array list - /*! - \param value The value to push back - */ - void PushBackValue(AMFValue* value); - - //! Pops back the last value in the array list - void PopBackValue(); - - //! Gets the count of the dense list - /*! - \return The dense list size - */ - uint32_t GetDenseValueSize(); - - //! Gets a specific value from the list for the specified index - /*! - \param index The index to get - */ - template - T* GetValueAt(uint32_t index) { - if (index >= this->dense.size()) return nullptr; - AMFValue* foundValue = this->dense.at(index); - return T::ValueType == foundValue->GetValueType() ? dynamic_cast(foundValue) : nullptr; - }; - - //! Returns where the dense iterator begins - /*! - \return Where the iterator begins - */ - _AMFArrayList_::iterator GetDenseIteratorBegin(); - - //! Returns where the dense iterator ends - /*! - \return Where the iterator ends - */ - _AMFArrayList_::iterator GetDenseIteratorEnd(); - - //! Returns the associative map - /*! - \return The associative map - */ - _AMFArrayMap_ GetAssociativeMap() { return this->associative; }; - - //! Returns the dense array - /*! - \return The dense array - */ - _AMFArrayList_ GetDenseArray() { return this->dense; }; -}; - -//! The anonymous object value AMF type -class AMFObjectValue : public AMFValue { -private: - _AMFObjectTraits_ traits; //!< The object traits - - //! Returns the AMF value type - /*! - \return The AMF value type - */ - AMFValueType GetValueType() override { return ValueType; } - ~AMFObjectValue() override; - -public: - static const AMFValueType ValueType = AMFObject; - //! Constructor - /*! - \param traits The traits to set - */ - AMFObjectValue(std::vector> traits); - - //! Gets the object value type - /*! - \return The object value type - */ - virtual AMFObjectValueType GetObjectValueType() { return AMFObjectAnonymous; } - - //! Sets the value of a trait - /*! - \param trait The trait to set the value for - \param value The AMF value to set - */ - void SetTraitValue(const std::string& trait, AMFValue* value); - - //! Gets a trait value - /*! - \param trait The trait to get the value for - \return The trait value - */ - AMFValue* GetTraitValue(const std::string& trait); - - //! Gets the beginning of the object traits iterator - /*! - \return The AMF trait array iterator begin - */ - _AMFObjectTraits_::iterator GetTraitsIteratorBegin(); - - //! Gets the end of the object traits iterator - /*! - \return The AMF trait array iterator begin - */ - _AMFObjectTraits_::iterator GetTraitsIteratorEnd(); - - //! Gets the amount of traits - /*! - \return The amount of traits - */ - uint32_t GetTraitArrayCount(); -}; diff --git a/dCommon/AMFFormat_BitStream.cpp b/dCommon/AMFFormat_BitStream.cpp deleted file mode 100644 index b603ba31..00000000 --- a/dCommon/AMFFormat_BitStream.cpp +++ /dev/null @@ -1,250 +0,0 @@ -#include "AMFFormat_BitStream.h" - -// Writes an AMFValue pointer to a RakNet::BitStream -template<> -void RakNet::BitStream::Write(AMFValue* value) { - if (value != nullptr) { - AMFValueType type = value->GetValueType(); - - switch (type) { - case AMFUndefined: { - AMFUndefinedValue* v = (AMFUndefinedValue*)value; - this->Write(*v); - break; - } - - case AMFNull: { - AMFNullValue* v = (AMFNullValue*)value; - this->Write(*v); - break; - } - - case AMFFalse: { - AMFFalseValue* v = (AMFFalseValue*)value; - this->Write(*v); - break; - } - - case AMFTrue: { - AMFTrueValue* v = (AMFTrueValue*)value; - this->Write(*v); - break; - } - - case AMFInteger: { - AMFIntegerValue* v = (AMFIntegerValue*)value; - this->Write(*v); - break; - } - - case AMFDouble: { - AMFDoubleValue* v = (AMFDoubleValue*)value; - this->Write(*v); - break; - } - - case AMFString: { - AMFStringValue* v = (AMFStringValue*)value; - this->Write(*v); - break; - } - - case AMFXMLDoc: { - AMFXMLDocValue* v = (AMFXMLDocValue*)value; - this->Write(*v); - break; - } - - case AMFDate: { - AMFDateValue* v = (AMFDateValue*)value; - this->Write(*v); - break; - } - - case AMFArray: { - this->Write((AMFArrayValue*)value); - break; - } - } - } -} - -/** - * A private function to write an value to a RakNet::BitStream - * RakNet writes in the correct byte order - do not reverse this. - */ -void WriteUInt29(RakNet::BitStream* bs, uint32_t v) { - unsigned char b4 = (unsigned char)v; - if (v < 0x00200000) { - b4 = b4 & 0x7F; - if (v > 0x7F) { - unsigned char b3; - v = v >> 7; - b3 = ((unsigned char)(v)) | 0x80; - if (v > 0x7F) { - unsigned char b2; - v = v >> 7; - b2 = ((unsigned char)(v)) | 0x80; - bs->Write(b2); - } - - bs->Write(b3); - } - } else { - unsigned char b1; - unsigned char b2; - unsigned char b3; - - v = v >> 8; - b3 = ((unsigned char)(v)) | 0x80; - v = v >> 7; - b2 = ((unsigned char)(v)) | 0x80; - v = v >> 7; - b1 = ((unsigned char)(v)) | 0x80; - - bs->Write(b1); - bs->Write(b2); - bs->Write(b3); - } - - bs->Write(b4); -} - -/** - * Writes a flag number to a RakNet::BitStream - * RakNet writes in the correct byte order - do not reverse this. - */ -void WriteFlagNumber(RakNet::BitStream* bs, uint32_t v) { - v = (v << 1) | 0x01; - WriteUInt29(bs, v); -} - -/** - * Writes an AMFString to a RakNet::BitStream - * - * RakNet writes in the correct byte order - do not reverse this. - */ -void WriteAMFString(RakNet::BitStream* bs, const std::string& str) { - WriteFlagNumber(bs, (uint32_t)str.size()); - bs->Write(str.c_str(), (uint32_t)str.size()); -} - -/** - * Writes an U16 to a bitstream - * - * RakNet writes in the correct byte order - do not reverse this. - */ -void WriteAMFU16(RakNet::BitStream* bs, uint16_t value) { - bs->Write(value); -} - -/** - * Writes an U32 to a bitstream - * - * RakNet writes in the correct byte order - do not reverse this. - */ -void WriteAMFU32(RakNet::BitStream* bs, uint32_t value) { - bs->Write(value); -} - -/** - * Writes an U64 to a bitstream - * - * RakNet writes in the correct byte order - do not reverse this. - */ -void WriteAMFU64(RakNet::BitStream* bs, uint64_t value) { - bs->Write(value); -} - - -// Writes an AMFUndefinedValue to BitStream -template<> -void RakNet::BitStream::Write(AMFUndefinedValue value) { - this->Write(AMFUndefined); -} - -// Writes an AMFNullValue to BitStream -template<> -void RakNet::BitStream::Write(AMFNullValue value) { - this->Write(AMFNull); -} - -// Writes an AMFFalseValue to BitStream -template<> -void RakNet::BitStream::Write(AMFFalseValue value) { - this->Write(AMFFalse); -} - -// Writes an AMFTrueValue to BitStream -template<> -void RakNet::BitStream::Write(AMFTrueValue value) { - this->Write(AMFTrue); -} - -// Writes an AMFIntegerValue to BitStream -template<> -void RakNet::BitStream::Write(AMFIntegerValue value) { - this->Write(AMFInteger); - WriteUInt29(this, value.GetIntegerValue()); -} - -// Writes an AMFDoubleValue to BitStream -template<> -void RakNet::BitStream::Write(AMFDoubleValue value) { - this->Write(AMFDouble); - double d = value.GetDoubleValue(); - WriteAMFU64(this, *((unsigned long long*) & d)); -} - -// Writes an AMFStringValue to BitStream -template<> -void RakNet::BitStream::Write(AMFStringValue value) { - this->Write(AMFString); - std::string v = value.GetStringValue(); - WriteAMFString(this, v); -} - -// Writes an AMFXMLDocValue to BitStream -template<> -void RakNet::BitStream::Write(AMFXMLDocValue value) { - this->Write(AMFXMLDoc); - std::string v = value.GetXMLDocValue(); - WriteAMFString(this, v); -} - -// Writes an AMFDateValue to BitStream -template<> -void RakNet::BitStream::Write(AMFDateValue value) { - this->Write(AMFDate); - uint64_t date = value.GetDateValue(); - WriteAMFU64(this, date); -} - -// Writes an AMFArrayValue to BitStream -template<> -void RakNet::BitStream::Write(AMFArrayValue* value) { - this->Write(AMFArray); - uint32_t denseSize = value->GetDenseValueSize(); - WriteFlagNumber(this, denseSize); - - _AMFArrayMap_::iterator it = value->GetAssociativeIteratorValueBegin(); - _AMFArrayMap_::iterator end = value->GetAssociativeIteratorValueEnd(); - - while (it != end) { - WriteAMFString(this, it->first); - this->Write(it->second); - it++; - } - - this->Write(AMFNull); - - if (denseSize > 0) { - _AMFArrayList_::iterator it2 = value->GetDenseIteratorBegin(); - _AMFArrayList_::iterator end2 = value->GetDenseIteratorEnd(); - - while (it2 != end2) { - this->Write(*it2); - it2++; - } - } -} diff --git a/dCommon/AMFFormat_BitStream.h b/dCommon/AMFFormat_BitStream.h deleted file mode 100644 index caa49337..00000000 --- a/dCommon/AMFFormat_BitStream.h +++ /dev/null @@ -1,92 +0,0 @@ -#pragma once - -// Custom Classes -#include "AMFFormat.h" - -// RakNet -#include - -/*! - \file AMFFormat_BitStream.h - \brief A class that implements native writing of AMF values to RakNet::BitStream - */ - - // We are using the RakNet namespace -namespace RakNet { - //! Writes an AMFValue pointer to a RakNet::BitStream - /*! - \param value The value to write - */ - template <> - void RakNet::BitStream::Write(AMFValue* value); - - //! Writes an AMFUndefinedValue to a RakNet::BitStream - /*! - \param value The value to write - */ - template <> - void RakNet::BitStream::Write(AMFUndefinedValue value); - - //! Writes an AMFNullValue to a RakNet::BitStream - /*! - \param value The value to write - */ - template <> - void RakNet::BitStream::Write(AMFNullValue value); - - //! Writes an AMFFalseValue to a RakNet::BitStream - /*! - \param value The value to write - */ - template <> - void RakNet::BitStream::Write(AMFFalseValue value); - - //! Writes an AMFTrueValue to a RakNet::BitStream - /*! - \param value The value to write - */ - template <> - void RakNet::BitStream::Write(AMFTrueValue value); - - //! Writes an AMFIntegerValue to a RakNet::BitStream - /*! - \param value The value to write - */ - template <> - void RakNet::BitStream::Write(AMFIntegerValue value); - - //! Writes an AMFDoubleValue to a RakNet::BitStream - /*! - \param value The value to write - */ - template <> - void RakNet::BitStream::Write(AMFDoubleValue value); - - //! Writes an AMFStringValue to a RakNet::BitStream - /*! - \param value The value to write - */ - template <> - void RakNet::BitStream::Write(AMFStringValue value); - - //! Writes an AMFXMLDocValue to a RakNet::BitStream - /*! - \param value The value to write - */ - template <> - void RakNet::BitStream::Write(AMFXMLDocValue value); - - //! Writes an AMFDateValue to a RakNet::BitStream - /*! - \param value The value to write - */ - template <> - void RakNet::BitStream::Write(AMFDateValue value); - - //! Writes an AMFArrayValue to a RakNet::BitStream - /*! - \param value The value to write - */ - template <> - void RakNet::BitStream::Write(AMFArrayValue* value); -} // namespace RakNet diff --git a/dCommon/Amf3.h b/dCommon/Amf3.h new file mode 100644 index 00000000..4dba039f --- /dev/null +++ b/dCommon/Amf3.h @@ -0,0 +1,368 @@ +#ifndef __AMF3__H__ +#define __AMF3__H__ + +#include "dCommonVars.h" +#include "dLogger.h" +#include "Game.h" + +#include +#include + +enum class eAmf : uint8_t { + Undefined = 0x00, // An undefined AMF Value + Null = 0x01, // A null AMF value + False = 0x02, // A false AMF value + True = 0x03, // A true AMF value + Integer = 0x04, // An integer AMF value + Double = 0x05, // A double AMF value + String = 0x06, // A string AMF value + XMLDoc = 0x07, // Unused in the live client and cannot be serialized without modification. An XML Doc AMF value + Date = 0x08, // Unused in the live client and cannot be serialized without modification. A date AMF value + Array = 0x09, // An array AMF value + Object = 0x0A, // Unused in the live client and cannot be serialized without modification. An object AMF value + XML = 0x0B, // Unused in the live client and cannot be serialized without modification. An XML AMF value + ByteArray = 0x0C, // Unused in the live client and cannot be serialized without modification. A byte array AMF value + VectorInt = 0x0D, // Unused in the live client and cannot be serialized without modification. An integer vector AMF value + VectorUInt = 0x0E, // Unused in the live client and cannot be serialized without modification. An unsigned integer AMF value + VectorDouble = 0x0F, // Unused in the live client and cannot be serialized without modification. A double vector AMF value + VectorObject = 0x10, // Unused in the live client and cannot be serialized without modification. An object vector AMF value + Dictionary = 0x11 // Unused in the live client and cannot be serialized without modification. A dictionary AMF value +}; + +class AMFBaseValue { +public: + virtual eAmf GetValueType() { return eAmf::Undefined; }; + AMFBaseValue() {}; + virtual ~AMFBaseValue() {}; +}; + +template +class AMFValue : public AMFBaseValue { +public: + AMFValue() {}; + AMFValue(ValueType value) { SetValue(value); }; + virtual ~AMFValue() override {}; + + eAmf GetValueType() override { return eAmf::Undefined; }; + + const ValueType& GetValue() { return data; }; + void SetValue(ValueType value) { data = value; }; +protected: + ValueType data; +}; + +// As a string this is much easier to write and read from a BitStream. +template<> +class AMFValue : public AMFBaseValue { +public: + AMFValue() {}; + AMFValue(const char* value) { SetValue(std::string(value)); }; + virtual ~AMFValue() override {}; + + eAmf GetValueType() override { return eAmf::String; }; + + const std::string& GetValue() { return data; }; + void SetValue(std::string value) { data = value; }; +protected: + std::string data; +}; + +typedef AMFValue AMFNullValue; +typedef AMFValue AMFBoolValue; +typedef AMFValue AMFIntValue; +typedef AMFValue AMFStringValue; +typedef AMFValue AMFDoubleValue; + +template<> inline eAmf AMFValue::GetValueType() { return eAmf::Null; }; +template<> inline eAmf AMFValue::GetValueType() { return this->data ? eAmf::True : eAmf::False; }; +template<> inline eAmf AMFValue::GetValueType() { return eAmf::Integer; }; +template<> inline eAmf AMFValue::GetValueType() { return eAmf::Integer; }; +template<> inline eAmf AMFValue::GetValueType() { return eAmf::String; }; +template<> inline eAmf AMFValue::GetValueType() { return eAmf::Double; }; + +/** + * The AMFArrayValue object holds 2 types of lists: + * An associative list where a key maps to a value + * A Dense list where elements are stored back to back + * + * Objects that are Registered are owned by this object + * and are not to be deleted by a caller. + */ +class AMFArrayValue : public AMFBaseValue { + + typedef std::unordered_map AMFAssociative; + typedef std::vector AMFDense; + +public: + eAmf GetValueType() override { return eAmf::Array; }; + + ~AMFArrayValue() override { + for (auto valueToDelete : GetDense()) { + if (valueToDelete) { + delete valueToDelete; + valueToDelete = nullptr; + } + } + for (auto valueToDelete : GetAssociative()) { + if (valueToDelete.second) { + delete valueToDelete.second; + valueToDelete.second = nullptr; + } + } + }; + + /** + * Returns the Associative portion of the object + */ + inline AMFAssociative& GetAssociative() { return this->associative; }; + + /** + * Returns the dense portion of the object + */ + inline AMFDense& GetDense() { return this->dense; }; + + /** + * Inserts an AMFValue into the associative portion with the given key. + * If a duplicate is attempted to be inserted, it is ignored and the + * first value with that key is kept in the map. + * + * These objects are not to be deleted by the caller as they are owned by + * the AMFArray object which manages its own memory. + * + * @param key The key to associate with the value + * @param value The value to insert + * + * @return The inserted element if the type matched, + * or nullptr if a key existed and was not the same type + */ + template + std::pair*, bool> Insert(const std::string& key, ValueType value) { + auto element = associative.find(key); + AMFValue* val = nullptr; + bool found = true; + if (element == associative.end()) { + val = new AMFValue(value); + associative.insert(std::make_pair(key, val)); + } else { + val = dynamic_cast*>(element->second); + found = false; + } + return std::make_pair(val, found); + }; + + // Associates an array with a string key + std::pair Insert(const std::string& key) { + auto element = associative.find(key); + AMFArrayValue* val = nullptr; + bool found = true; + if (element == associative.end()) { + val = new AMFArrayValue(); + associative.insert(std::make_pair(key, val)); + } else { + val = dynamic_cast(element->second); + found = false; + } + return std::make_pair(val, found); + }; + + // Associates an array with an integer key + std::pair Insert(const uint32_t& index) { + AMFArrayValue* val = nullptr; + bool inserted = false; + if (index >= dense.size()) { + dense.resize(index + 1); + val = new AMFArrayValue(); + dense.at(index) = val; + inserted = true; + } + return std::make_pair(dynamic_cast(dense.at(index)), inserted); + }; + + /** + * @brief Inserts an AMFValue into the AMFArray key'd by index. + * Attempting to insert the same key to the same value twice overwrites + * the previous value with the new one. + * + * @param index The index to associate with the value + * @param value The value to insert + * @return The inserted element, or nullptr if the type did not match + * what was at the index. + */ + template + std::pair*, bool> Insert(const uint32_t& index, ValueType value) { + AMFValue* val = nullptr; + bool inserted = false; + if (index >= this->dense.size()) { + this->dense.resize(index + 1); + val = new AMFValue(value); + this->dense.at(index) = val; + inserted = true; + } + return std::make_pair(dynamic_cast*>(this->dense.at(index)), inserted); + }; + + /** + * Inserts an AMFValue into the associative portion with the given key. + * If a duplicate is attempted to be inserted, it replaces the original + * + * The inserted element is now owned by this object and is not to be deleted + * + * @param key The key to associate with the value + * @param value The value to insert + */ + void Insert(const std::string& key, AMFBaseValue* value) { + auto element = associative.find(key); + if (element != associative.end() && element->second) { + delete element->second; + element->second = value; + } else { + associative.insert(std::make_pair(key, value)); + } + }; + + /** + * Inserts an AMFValue into the associative portion with the given index. + * If a duplicate is attempted to be inserted, it replaces the original + * + * The inserted element is now owned by this object and is not to be deleted + * + * @param key The key to associate with the value + * @param value The value to insert + */ + void Insert(const uint32_t index, AMFBaseValue* value) { + if (index < dense.size()) { + AMFDense::iterator itr = dense.begin() + index; + if (*itr) delete dense.at(index); + } else { + dense.resize(index + 1); + } + dense.at(index) = value; + }; + + /** + * Pushes an AMFValue into the back of the dense portion. + * + * These objects are not to be deleted by the caller as they are owned by + * the AMFArray object which manages its own memory. + * + * @param value The value to insert + * + * @return The inserted pointer, or nullptr should the key already be in use. + */ + template + inline AMFValue* Push(ValueType value) { + return Insert(this->dense.size(), value).first; + }; + + /** + * Removes the key from the associative portion + * + * The pointer removed is now no longer managed by this container + * + * @param key The key to remove from the associative portion + */ + void Remove(const std::string& key, bool deleteValue = true) { + AMFAssociative::iterator it = this->associative.find(key); + if (it != this->associative.end()) { + if (deleteValue) delete it->second; + this->associative.erase(it); + } + } + + /** + * Pops the last element in the dense portion, deleting it in the process. + */ + void Remove(const uint32_t index) { + if (!this->dense.empty() && index < this->dense.size()) { + auto itr = this->dense.begin() + index; + if (*itr) delete (*itr); + this->dense.erase(itr); + } + } + + void Pop() { + if (!this->dense.empty()) Remove(this->dense.size() - 1); + } + + AMFArrayValue* GetArray(const std::string& key) { + AMFAssociative::const_iterator it = this->associative.find(key); + if (it != this->associative.end()) { + return dynamic_cast(it->second); + } + return nullptr; + }; + + AMFArrayValue* GetArray(const uint32_t index) { + return index >= this->dense.size() ? nullptr : dynamic_cast(this->dense.at(index)); + }; + + inline AMFArrayValue* InsertArray(const std::string& key) { + return static_cast(Insert(key).first); + }; + + inline AMFArrayValue* InsertArray(const uint32_t index) { + return static_cast(Insert(index).first); + }; + + inline AMFArrayValue* PushArray() { + return static_cast(Insert(this->dense.size()).first); + }; + + /** + * Gets an AMFValue by the key from the associative portion and converts it + * to the AmfValue template type. If the key did not exist, it is inserted. + * + * @tparam The target object type + * @param key The key to lookup + * + * @return The AMFValue + */ + template + AMFValue* Get(const std::string& key) const { + AMFAssociative::const_iterator it = this->associative.find(key); + return it != this->associative.end() ? + dynamic_cast*>(it->second) : + nullptr; + }; + + // Get from the array but dont cast it + AMFBaseValue* Get(const std::string& key) const { + AMFAssociative::const_iterator it = this->associative.find(key); + return it != this->associative.end() ? it->second : nullptr; + }; + + /** + * @brief Get an AMFValue object at a position in the dense portion. + * Gets an AMFValue by the index from the dense portion and converts it + * to the AmfValue template type. If the index did not exist, it is inserted. + * + * @tparam The target object type + * @param index The index to get + * @return The casted object, or nullptr. + */ + template + AMFValue* Get(uint32_t index) const { + std::cout << (index < this->dense.size()) << std::endl; + return index < this->dense.size() ? + dynamic_cast*>(this->dense.at(index)) : + nullptr; + }; + + // Get from the dense but dont cast it + AMFBaseValue* Get(const uint32_t index) const { + return index < this->dense.size() ? this->dense.at(index) : nullptr; + }; +private: + /** + * The associative portion. These values are key'd with strings to an AMFValue. + */ + AMFAssociative associative; + + /** + * The dense portion. These AMFValue's are stored one after + * another with the most recent addition being at the back. + */ + AMFDense dense; +}; + +#endif //!__AMF3__H__ diff --git a/dCommon/AmfSerialize.cpp b/dCommon/AmfSerialize.cpp new file mode 100644 index 00000000..79ba5e2d --- /dev/null +++ b/dCommon/AmfSerialize.cpp @@ -0,0 +1,184 @@ +#include "AmfSerialize.h" + +#include "Game.h" +#include "dLogger.h" + +// Writes an AMFValue pointer to a RakNet::BitStream +template<> +void RakNet::BitStream::Write(AMFBaseValue& value) { + eAmf type = value.GetValueType(); + this->Write(type); + switch (type) { + case eAmf::Integer: { + this->Write(*static_cast(&value)); + break; + } + + case eAmf::Double: { + this->Write(*static_cast(&value)); + break; + } + + case eAmf::String: { + this->Write(*static_cast(&value)); + break; + } + + case eAmf::Array: { + this->Write(*static_cast(&value)); + break; + } + default: { + Game::logger->Log("AmfSerialize", "Encountered unwritable AMFType %i!", type); + } + case eAmf::Undefined: + case eAmf::Null: + case eAmf::False: + case eAmf::True: + case eAmf::Date: + case eAmf::Object: + case eAmf::XML: + case eAmf::XMLDoc: + case eAmf::ByteArray: + case eAmf::VectorInt: + case eAmf::VectorUInt: + case eAmf::VectorDouble: + case eAmf::VectorObject: + case eAmf::Dictionary: + break; + } +} + +/** + * A private function to write an value to a RakNet::BitStream + * RakNet writes in the correct byte order - do not reverse this. + */ +void WriteUInt29(RakNet::BitStream* bs, uint32_t v) { + unsigned char b4 = (unsigned char)v; + if (v < 0x00200000) { + b4 = b4 & 0x7F; + if (v > 0x7F) { + unsigned char b3; + v = v >> 7; + b3 = ((unsigned char)(v)) | 0x80; + if (v > 0x7F) { + unsigned char b2; + v = v >> 7; + b2 = ((unsigned char)(v)) | 0x80; + bs->Write(b2); + } + + bs->Write(b3); + } + } else { + unsigned char b1; + unsigned char b2; + unsigned char b3; + + v = v >> 8; + b3 = ((unsigned char)(v)) | 0x80; + v = v >> 7; + b2 = ((unsigned char)(v)) | 0x80; + v = v >> 7; + b1 = ((unsigned char)(v)) | 0x80; + + bs->Write(b1); + bs->Write(b2); + bs->Write(b3); + } + + bs->Write(b4); +} + +/** + * Writes a flag number to a RakNet::BitStream + * RakNet writes in the correct byte order - do not reverse this. + */ +void WriteFlagNumber(RakNet::BitStream* bs, uint32_t v) { + v = (v << 1) | 0x01; + WriteUInt29(bs, v); +} + +/** + * Writes an AMFString to a RakNet::BitStream + * + * RakNet writes in the correct byte order - do not reverse this. + */ +void WriteAMFString(RakNet::BitStream* bs, const std::string& str) { + WriteFlagNumber(bs, (uint32_t)str.size()); + bs->Write(str.c_str(), (uint32_t)str.size()); +} + +/** + * Writes an U16 to a bitstream + * + * RakNet writes in the correct byte order - do not reverse this. + */ +void WriteAMFU16(RakNet::BitStream* bs, uint16_t value) { + bs->Write(value); +} + +/** + * Writes an U32 to a bitstream + * + * RakNet writes in the correct byte order - do not reverse this. + */ +void WriteAMFU32(RakNet::BitStream* bs, uint32_t value) { + bs->Write(value); +} + +/** + * Writes an U64 to a bitstream + * + * RakNet writes in the correct byte order - do not reverse this. + */ +void WriteAMFU64(RakNet::BitStream* bs, uint64_t value) { + bs->Write(value); +} + +// Writes an AMFIntegerValue to BitStream +template<> +void RakNet::BitStream::Write(AMFIntValue& value) { + WriteUInt29(this, value.GetValue()); +} + +// Writes an AMFDoubleValue to BitStream +template<> +void RakNet::BitStream::Write(AMFDoubleValue& value) { + double d = value.GetValue(); + WriteAMFU64(this, *reinterpret_cast(&d)); +} + +// Writes an AMFStringValue to BitStream +template<> +void RakNet::BitStream::Write(AMFStringValue& value) { + WriteAMFString(this, value.GetValue()); +} + +// Writes an AMFArrayValue to BitStream +template<> +void RakNet::BitStream::Write(AMFArrayValue& value) { + uint32_t denseSize = value.GetDense().size(); + WriteFlagNumber(this, denseSize); + + auto it = value.GetAssociative().begin(); + auto end = value.GetAssociative().end(); + + while (it != end) { + WriteAMFString(this, it->first); + this->Write(*it->second); + it++; + } + + this->Write(eAmf::Null); + + if (denseSize > 0) { + auto it2 = value.GetDense().begin(); + auto end2 = value.GetDense().end(); + + while (it2 != end2) { + this->Write(**it2); + it2++; + } + } +} diff --git a/dCommon/AmfSerialize.h b/dCommon/AmfSerialize.h new file mode 100644 index 00000000..9a6f56f2 --- /dev/null +++ b/dCommon/AmfSerialize.h @@ -0,0 +1,50 @@ +#pragma once + +// Custom Classes +#include "Amf3.h" + +// RakNet +#include + +/*! + \file AmfSerialize.h + \brief A class that implements native writing of AMF values to RakNet::BitStream + */ + + // We are using the RakNet namespace +namespace RakNet { + //! Writes an AMFValue pointer to a RakNet::BitStream + /*! + \param value The value to write + */ + template <> + void RakNet::BitStream::Write(AMFBaseValue& value); + + //! Writes an AMFIntegerValue to a RakNet::BitStream + /*! + \param value The value to write + */ + template <> + void RakNet::BitStream::Write(AMFIntValue& value); + + //! Writes an AMFDoubleValue to a RakNet::BitStream + /*! + \param value The value to write + */ + template <> + void RakNet::BitStream::Write(AMFDoubleValue& value); + + //! Writes an AMFStringValue to a RakNet::BitStream + /*! + \param value The value to write + */ + template <> + void RakNet::BitStream::Write(AMFStringValue& value); + + //! Writes an AMFArrayValue to a RakNet::BitStream + /*! + \param value The value to write + */ + template <> + void RakNet::BitStream::Write(AMFArrayValue& value); +} // namespace RakNet diff --git a/dCommon/Brick.h b/dCommon/Brick.h new file mode 100644 index 00000000..e8bd747e --- /dev/null +++ b/dCommon/Brick.h @@ -0,0 +1,11 @@ +#ifndef __BRICK__H__ +#define __BRICK__H__ + +#include + +struct Brick { + uint32_t designerID; + uint32_t materialID; +}; + +#endif //!__BRICK__H__ diff --git a/dCommon/CMakeLists.txt b/dCommon/CMakeLists.txt index 549acfb2..2517c048 100644 --- a/dCommon/CMakeLists.txt +++ b/dCommon/CMakeLists.txt @@ -1,6 +1,6 @@ -set(DCOMMON_SOURCES "AMFFormat.cpp" +set(DCOMMON_SOURCES "AMFDeserialize.cpp" - "AMFFormat_BitStream.cpp" + "AmfSerialize.cpp" "BinaryIO.cpp" "dConfig.cpp" "Diagnostics.cpp" diff --git a/dCommon/Diagnostics.cpp b/dCommon/Diagnostics.cpp index 3025f083..58d558de 100644 --- a/dCommon/Diagnostics.cpp +++ b/dCommon/Diagnostics.cpp @@ -111,7 +111,7 @@ static void ErrorCallback(void* data, const char* msg, int errnum) { void GenerateDump() { std::string cmd = "sudo gcore " + std::to_string(getpid()); - system(cmd.c_str()); + int ret = system(cmd.c_str()); // Saving a return just to prevent warning } void CatchUnhandled(int sig) { diff --git a/dCommon/GeneralUtils.cpp b/dCommon/GeneralUtils.cpp index df641a1b..99ca687a 100644 --- a/dCommon/GeneralUtils.cpp +++ b/dCommon/GeneralUtils.cpp @@ -241,7 +241,7 @@ std::vector GeneralUtils::SplitString(std::wstring& str, wchar_t d return vector; } -std::vector GeneralUtils::SplitString(std::u16string& str, char16_t delimiter) { +std::vector GeneralUtils::SplitString(const std::u16string& str, char16_t delimiter) { std::vector vector = std::vector(); std::u16string current; diff --git a/dCommon/GeneralUtils.h b/dCommon/GeneralUtils.h index 25aac783..0a8a0a16 100644 --- a/dCommon/GeneralUtils.h +++ b/dCommon/GeneralUtils.h @@ -16,6 +16,7 @@ #include "dLogger.h" enum eInventoryType : uint32_t; +enum class eObjectBits : size_t; enum class eReplicaComponentType : uint32_t; /*! @@ -66,9 +67,9 @@ namespace GeneralUtils { //! Sets a bit on a numerical value template - void SetBit(T& value, size_t index) { + inline void SetBit(T& value, eObjectBits bits) { static_assert(std::is_arithmetic::value, "Not an arithmetic type"); - + auto index = static_cast(bits); if (index > (sizeof(T) * 8) - 1) { return; } @@ -78,9 +79,9 @@ namespace GeneralUtils { //! Clears a bit on a numerical value template - void ClearBit(T& value, size_t index) { + inline void ClearBit(T& value, eObjectBits bits) { static_assert(std::is_arithmetic::value, "Not an arithmetic type"); - + auto index = static_cast(bits); if (index > (sizeof(T) * 8 - 1)) { return; } @@ -139,7 +140,7 @@ namespace GeneralUtils { std::vector SplitString(std::wstring& str, wchar_t delimiter); - std::vector SplitString(std::u16string& str, char16_t delimiter); + std::vector SplitString(const std::u16string& str, char16_t delimiter); std::vector SplitString(const std::string& str, char delimiter); diff --git a/dCommon/LDFFormat.cpp b/dCommon/LDFFormat.cpp index 767ec81a..cb921842 100644 --- a/dCommon/LDFFormat.cpp +++ b/dCommon/LDFFormat.cpp @@ -3,122 +3,174 @@ // Custom Classes #include "GeneralUtils.h" +#include "Game.h" +#include "dLogger.h" + // C++ -#include +#include #include +using LDFKey = std::string_view; +using LDFTypeAndValue = std::string_view; + +using LDFType = std::string_view; +using LDFValue = std::string_view; + //! Returns a pointer to a LDFData value based on string format -LDFBaseData* LDFBaseData::DataFromString(const std::string& format) { +LDFBaseData* LDFBaseData::DataFromString(const std::string_view& format) { + // A valid LDF must be at least 3 characters long (=0:) is the shortest valid LDF (empty UTF-16 key with no initial value) + if (format.empty() || format.length() <= 2) return nullptr; + auto equalsPosition = format.find('='); + // You can have an empty key, just make sure the type and value might exist + if (equalsPosition == std::string::npos || equalsPosition == (format.size() - 1)) return nullptr; - // First, check the format - std::istringstream ssFormat(format); - std::string token; + std::pair keyValue; + keyValue.first = format.substr(0, equalsPosition); + keyValue.second = format.substr(equalsPosition + 1, format.size()); - std::vector keyValueArray; - while (std::getline(ssFormat, token, '=')) { - keyValueArray.push_back(token); + std::u16string key = GeneralUtils::ASCIIToUTF16(keyValue.first); + + auto colonPosition = keyValue.second.find(':'); + + // If : is the first thing after an =, then this is an invalid LDF since + // we dont have a type to use. + if (colonPosition == std::string::npos || colonPosition == 0) return nullptr; + + std::pair ldfTypeAndValue; + ldfTypeAndValue.first = keyValue.second.substr(0, colonPosition); + ldfTypeAndValue.second = keyValue.second.substr(colonPosition + 1, keyValue.second.size()); + + // Only allow empty values for string values. + if (ldfTypeAndValue.second.size() == 0 && !(ldfTypeAndValue.first == "0" || ldfTypeAndValue.first == "13")) return nullptr; + + eLDFType type; + char* storage; + try { + type = static_cast(strtol(ldfTypeAndValue.first.data(), &storage, 10)); + } catch (std::exception) { + Game::logger->Log("LDFFormat", "Attempted to process invalid ldf type (%s) from string (%s)", ldfTypeAndValue.first.data(), format.data()); + return nullptr; } - if (keyValueArray.size() == 2) { - std::u16string key = GeneralUtils::ASCIIToUTF16(keyValueArray[0]); + LDFBaseData* returnValue = nullptr; + switch (type) { + case LDF_TYPE_UTF_16: { + std::u16string data = GeneralUtils::UTF8ToUTF16(ldfTypeAndValue.second); + returnValue = new LDFData(key, data); + break; + } - std::vector dataArray; - std::istringstream ssData(keyValueArray[1]); - while (std::getline(ssData, token, ':')) { - dataArray.push_back(token); + case LDF_TYPE_S32: { + try { + int32_t data = static_cast(strtoul(ldfTypeAndValue.second.data(), &storage, 10)); + returnValue = new LDFData(key, data); + } catch (std::exception) { + Game::logger->Log("LDFFormat", "Warning: Attempted to process invalid int32 value (%s) from string (%s)", ldfTypeAndValue.second.data(), format.data()); + return nullptr; } + break; + } - if (dataArray.size() > 2) { // hacky fix for strings with colons in them - std::vector newDataArray; - newDataArray.push_back(dataArray[0]); - std::string value = ""; - for (size_t i = 1; i < dataArray.size(); ++i) { - value += dataArray[i] + ':'; - } - value.pop_back(); // remove last colon - newDataArray.push_back(value); - dataArray = newDataArray; + case LDF_TYPE_FLOAT: { + try { + float data = strtof(ldfTypeAndValue.second.data(), &storage); + returnValue = new LDFData(key, data); + } catch (std::exception) { + Game::logger->Log("LDFFormat", "Warning: Attempted to process invalid float value (%s) from string (%s)", ldfTypeAndValue.second.data(), format.data()); + return nullptr; } + break; + } - if ((dataArray[0] == "0" || dataArray[0] == "13") && dataArray.size() == 1) { - dataArray.push_back(""); + case LDF_TYPE_DOUBLE: { + try { + double data = strtod(ldfTypeAndValue.second.data(), &storage); + returnValue = new LDFData(key, data); + } catch (std::exception) { + Game::logger->Log("LDFFormat", "Warning: Attempted to process invalid double value (%s) from string (%s)", ldfTypeAndValue.second.data(), format.data()); + return nullptr; } + break; + } - if (dataArray.size() == 2) { - eLDFType type = static_cast(stoi(dataArray[0])); + case LDF_TYPE_U32: + { + uint32_t data; - switch (type) { - case LDF_TYPE_UTF_16: { - std::u16string data = GeneralUtils::UTF8ToUTF16(dataArray[1]); - return new LDFData(key, data); - } - - case LDF_TYPE_S32: { - int32_t data = static_cast(stoull(dataArray[1])); - return new LDFData(key, data); - } - - case LDF_TYPE_FLOAT: { - float data = static_cast(stof(dataArray[1])); - return new LDFData(key, data); - } - - case LDF_TYPE_DOUBLE: { - double data = static_cast(stod(dataArray[1])); - return new LDFData(key, data); - } - - case LDF_TYPE_U32: - { - uint32_t data; - - if (dataArray[1] == "true") { - data = 1; - } else if (dataArray[1] == "false") { - data = 0; - } else { - data = static_cast(stoul(dataArray[1])); - } - - return new LDFData(key, data); - } - - case LDF_TYPE_BOOLEAN: { - bool data; - - if (dataArray[1] == "true") { - data = true; - } else if (dataArray[1] == "false") { - data = false; - } else { - data = static_cast(stoi(dataArray[1])); - } - - return new LDFData(key, data); - } - - case LDF_TYPE_U64: { - uint64_t data = static_cast(stoull(dataArray[1])); - return new LDFData(key, data); - } - - case LDF_TYPE_OBJID: { - LWOOBJID data = static_cast(stoll(dataArray[1])); - return new LDFData(key, data); - } - - case LDF_TYPE_UTF_8: { - std::string data = dataArray[1]; - return new LDFData(key, data); - } - - case LDF_TYPE_UNKNOWN: { + if (ldfTypeAndValue.second == "true") { + data = 1; + } else if (ldfTypeAndValue.second == "false") { + data = 0; + } else { + try { + data = static_cast(strtoul(ldfTypeAndValue.second.data(), &storage, 10)); + } catch (std::exception) { + Game::logger->Log("LDFFormat", "Warning: Attempted to process invalid uint32 value (%s) from string (%s)", ldfTypeAndValue.second.data(), format.data()); return nullptr; } - } } + + returnValue = new LDFData(key, data); + break; } - return nullptr; + case LDF_TYPE_BOOLEAN: { + bool data; + if (ldfTypeAndValue.second == "true") { + data = true; + } else if (ldfTypeAndValue.second == "false") { + data = false; + } else { + try { + data = static_cast(strtol(ldfTypeAndValue.second.data(), &storage, 10)); + } catch (std::exception) { + Game::logger->Log("LDFFormat", "Warning: Attempted to process invalid bool value (%s) from string (%s)", ldfTypeAndValue.second.data(), format.data()); + return nullptr; + } + } + + returnValue = new LDFData(key, data); + break; + } + + case LDF_TYPE_U64: { + try { + uint64_t data = static_cast(strtoull(ldfTypeAndValue.second.data(), &storage, 10)); + returnValue = new LDFData(key, data); + } catch (std::exception) { + Game::logger->Log("LDFFormat", "Warning: Attempted to process invalid uint64 value (%s) from string (%s)", ldfTypeAndValue.second.data(), format.data()); + return nullptr; + } + break; + } + + case LDF_TYPE_OBJID: { + try { + LWOOBJID data = static_cast(strtoll(ldfTypeAndValue.second.data(), &storage, 10)); + returnValue = new LDFData(key, data); + } catch (std::exception) { + Game::logger->Log("LDFFormat", "Warning: Attempted to process invalid LWOOBJID value (%s) from string (%s)", ldfTypeAndValue.second.data(), format.data()); + return nullptr; + } + break; + } + + case LDF_TYPE_UTF_8: { + std::string data = ldfTypeAndValue.second.data(); + returnValue = new LDFData(key, data); + break; + } + + case LDF_TYPE_UNKNOWN: { + Game::logger->Log("LDFFormat", "Warning: Attempted to process invalid unknown value (%s) from string (%s)", ldfTypeAndValue.second.data(), format.data()); + break; + } + + default: { + Game::logger->Log("LDFFormat", "Warning: Attempted to process invalid LDF type (%d) from string (%s)", type, format.data()); + break; + } + } + return returnValue; } diff --git a/dCommon/LDFFormat.h b/dCommon/LDFFormat.h index 9b62efa7..0921d04c 100644 --- a/dCommon/LDFFormat.h +++ b/dCommon/LDFFormat.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef __LDFFORMAT__H__ +#define __LDFFORMAT__H__ // Custom Classes #include "dCommonVars.h" @@ -6,18 +7,12 @@ // C++ #include +#include #include // RakNet +#include "BitStream.h" -#include "../thirdparty/raknet/Source/BitStream.h" - -/*! - \file LDFFormat.hpp - \brief A collection of LDF format classes - */ - - //! An enum for LDF Data Types enum eLDFType { LDF_TYPE_UNKNOWN = -1, //!< Unknown data type LDF_TYPE_UTF_16 = 0, //!< UTF-16 wstring data type @@ -31,36 +26,21 @@ enum eLDFType { LDF_TYPE_UTF_8 = 13, //!< UTF-8 string data type }; -//! A base class for the LDF data class LDFBaseData { public: - //! Destructor - virtual ~LDFBaseData(void) {} + virtual ~LDFBaseData() {} - //! Writes the data to a packet - /*! - \param packet The packet - */ virtual void WriteToPacket(RakNet::BitStream* packet) = 0; - //! Gets the key - /*! - \return The key - */ - virtual const std::u16string& GetKey(void) = 0; + virtual const std::u16string& GetKey() = 0; - //! Gets the value type - /*! - \return The value type - */ - virtual eLDFType GetValueType(void) = 0; + virtual eLDFType GetValueType() = 0; - //! Gets a string from the key/value pair - /*! - \param includeKey Whether or not to include the key in the data - \param includeTypeId Whether or not to include the type id in the data - \return The string representation of the data + /** Gets a string from the key/value pair + * @param includeKey Whether or not to include the key in the data + * @param includeTypeId Whether or not to include the type id in the data + * @return The string representation of the data */ virtual std::string GetString(bool includeKey = true, bool includeTypeId = true) = 0; @@ -68,19 +48,15 @@ public: virtual LDFBaseData* Copy() = 0; - // MARK: Functions - - //! Returns a pointer to a LDFData value based on string format - /*! - \param format The format + /** + * Given an input string, return the data as a LDF key. */ - static LDFBaseData* DataFromString(const std::string& format); + static LDFBaseData* DataFromString(const std::string_view& format); }; -//! A structure for an LDF key-value pair template -class LDFData : public LDFBaseData { +class LDFData: public LDFBaseData { private: std::u16string key; T value; @@ -164,15 +140,11 @@ public: if (includeKey) { const std::string& sKey = GeneralUtils::UTF16ToWTF8(this->key, this->key.size()); - - stream << sKey << "="; + stream << sKey << '='; } if (includeTypeId) { - const std::string& sType = std::to_string(this->GetValueType()); - - - stream << sType << ":"; + stream << this->GetValueType() << ':'; } const std::string& sData = this->GetValueString(); @@ -234,20 +206,18 @@ inline void LDFData::WriteValue(RakNet::BitStream* packet) { } } -// MARK: String Data -template<> inline std::string LDFData::GetValueString(void) { - //std::string toReturn(this->value.begin(), this->value.end()); - //return toReturn; - +template<> inline std::string LDFData::GetValueString() { return GeneralUtils::UTF16ToWTF8(this->value, this->value.size()); } -template<> inline std::string LDFData::GetValueString(void) { return std::to_string(this->value); } -template<> inline std::string LDFData::GetValueString(void) { return std::to_string(this->value); } -template<> inline std::string LDFData::GetValueString(void) { return std::to_string(this->value); } -template<> inline std::string LDFData::GetValueString(void) { return std::to_string(this->value); } -template<> inline std::string LDFData::GetValueString(void) { return std::to_string(this->value); } -template<> inline std::string LDFData::GetValueString(void) { return std::to_string(this->value); } -template<> inline std::string LDFData::GetValueString(void) { return std::to_string(this->value); } +template<> inline std::string LDFData::GetValueString() { return std::to_string(this->value); } +template<> inline std::string LDFData::GetValueString() { return std::to_string(this->value); } +template<> inline std::string LDFData::GetValueString() { return std::to_string(this->value); } +template<> inline std::string LDFData::GetValueString() { return std::to_string(this->value); } +template<> inline std::string LDFData::GetValueString() { return std::to_string(this->value); } +template<> inline std::string LDFData::GetValueString() { return std::to_string(this->value); } +template<> inline std::string LDFData::GetValueString() { return std::to_string(this->value); } -template<> inline std::string LDFData::GetValueString(void) { return this->value; } +template<> inline std::string LDFData::GetValueString() { return this->value; } + +#endif //!__LDFFORMAT__H__ diff --git a/dCommon/dClient/AssetManager.cpp b/dCommon/dClient/AssetManager.cpp index ed86d719..00cedba9 100644 --- a/dCommon/dClient/AssetManager.cpp +++ b/dCommon/dClient/AssetManager.cpp @@ -47,6 +47,10 @@ AssetManager::AssetManager(const std::filesystem::path& path) { this->LoadPackIndex(); break; } + case eAssetBundleType::None: + case eAssetBundleType::Unpacked: { + break; + } } } @@ -111,7 +115,7 @@ bool AssetManager::GetFile(const char* name, char** data, uint32_t* len) { *len = ftell(file); *data = (char*)malloc(*len); fseek(file, 0, SEEK_SET); - fread(*data, sizeof(uint8_t), *len, file); + int32_t readInData = fread(*data, sizeof(uint8_t), *len, file); fclose(file); return true; diff --git a/dCommon/dClient/Pack.cpp b/dCommon/dClient/Pack.cpp index 1c1a643a..11345fc9 100644 --- a/dCommon/dClient/Pack.cpp +++ b/dCommon/dClient/Pack.cpp @@ -77,7 +77,7 @@ bool Pack::ReadFileFromPack(uint32_t crc, char** data, uint32_t* len) { if (!isCompressed) { char* tempData = (char*)malloc(pkRecord.m_UncompressedSize); - fread(tempData, sizeof(uint8_t), pkRecord.m_UncompressedSize, file); + int32_t readInData = fread(tempData, sizeof(uint8_t), pkRecord.m_UncompressedSize, file); *data = tempData; *len = pkRecord.m_UncompressedSize; @@ -97,11 +97,11 @@ bool Pack::ReadFileFromPack(uint32_t crc, char** data, uint32_t* len) { if (currentReadPos >= pkRecord.m_UncompressedSize) break; uint32_t size; - fread(&size, sizeof(uint32_t), 1, file); + int32_t readInData = fread(&size, sizeof(uint32_t), 1, file); pos += 4; // Move pointer position 4 to the right char* chunk = (char*)malloc(size); - fread(chunk, sizeof(int8_t), size, file); + int32_t readInData2 = fread(chunk, sizeof(int8_t), size, file); pos += size; // Move pointer position the amount of bytes read to the right int32_t err; diff --git a/dCommon/dEnums/dCommonVars.h b/dCommon/dEnums/dCommonVars.h index 16cae3c9..f67145da 100644 --- a/dCommon/dEnums/dCommonVars.h +++ b/dCommon/dEnums/dCommonVars.h @@ -7,11 +7,11 @@ #include #include #include "BitStream.h" +#include "eConnectionType.h" +#include "eClientMessageType.h" #pragma warning (disable:4251) //Disables SQL warnings -typedef int RESTICKET; - // These are the same define, but they mean two different things in different contexts // so a different define to distinguish what calculation is happening will help clarity. #define FRAMES_TO_MS(x) 1000 / x @@ -28,9 +28,11 @@ constexpr uint32_t lowFrameDelta = FRAMES_TO_MS(lowFramerate); //========== MACROS =========== +#define HEADER_SIZE 8 #define CBITSTREAM RakNet::BitStream bitStream; #define CINSTREAM RakNet::BitStream inStream(packet->data, packet->length, false); -#define CMSGHEADER PacketUtils::WriteHeader(bitStream, CLIENT, MSG_CLIENT_GAME_MSG); +#define CINSTREAM_SKIP_HEADER CINSTREAM if (inStream.GetNumberOfUnreadBits() >= BYTES_TO_BITS(HEADER_SIZE)) inStream.IgnoreBytes(HEADER_SIZE); else inStream.IgnoreBits(inStream.GetNumberOfUnreadBits()); +#define CMSGHEADER PacketUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::GAME_MSG); #define SEND_PACKET Game::server->Send(&bitStream, sysAddr, false); #define SEND_PACKET_BROADCAST Game::server->Send(&bitStream, UNASSIGNED_SYSTEM_ADDRESS, true); @@ -45,23 +47,16 @@ typedef uint16_t LWOINSTANCEID; //!< Used for Instance IDs typedef uint32_t PROPERTYCLONELIST; //!< Used for Property Clone IDs typedef uint32_t StripId; -typedef int32_t PetTamingPiece; //!< Pet Taming Pieces - const LWOOBJID LWOOBJID_EMPTY = 0; //!< An empty object ID const LOT LOT_NULL = -1; //!< A null LOT const int32_t LOOTTYPE_NONE = 0; //!< No loot type available const float SECONDARY_PRIORITY = 1.0f; //!< Secondary Priority -const uint32_t INVENTORY_INVALID = -1; //!< Invalid Inventory -const uint32_t INVENTORY_DEFAULT = -1; //!< Default Inventory -const uint32_t StatusChangeInfo = 0; //!< Status Change Info (???) const uint32_t INVENTORY_MAX = 9999999; //!< The Maximum Inventory Size const uint32_t LWOCLONEID_INVALID = -1; //!< Invalid LWOCLONEID const uint16_t LWOINSTANCEID_INVALID = -1; //!< Invalid LWOINSTANCEID const uint16_t LWOMAPID_INVALID = -1; //!< Invalid LWOMAPID const uint64_t LWOZONEID_INVALID = 0; //!< Invalid LWOZONEID -typedef std::set TSetObjID; - const float PI = 3.14159f; //============ STRUCTS ============== @@ -164,401 +159,4 @@ public: } }; -struct Brick { - uint32_t designerID; - uint32_t materialID; -}; - -//This union is used by the behavior system -union suchar { - unsigned char usigned; - char svalue; -}; - -//=========== LU ENUMS ============ - -//! An enum for object ID bits -enum eObjectBits : int32_t { - OBJECT_BIT_PERSISTENT = 32, //!< The 32 bit index - OBJECT_BIT_CLIENT = 46, //!< The 46 bit index - OBJECT_BIT_SPAWNED = 58, //!< The 58 bit index - OBJECT_BIT_CHARACTER = 60 //!< The 60 bit index -}; - -//! An enum for MatchUpdate types -enum eMatchUpdate : int { - MATCH_UPDATE_PLAYER_JOINED = 0, - MATCH_UPDATE_PLAYER_LEFT = 1, - MATCH_UPDATE_TIME = 3, - MATCH_UPDATE_TIME_START_DELAY = 4, - MATCH_UPDATE_PLAYER_READY = 5, - MATCH_UPDATE_PLAYER_UNREADY = 6 -}; - -//! An enum for camera cycling modes -enum eCyclingMode : uint32_t { - ALLOW_CYCLE_TEAMMATES, - DISALLOW_CYCLING -}; - -enum eCinematicEvent : uint32_t { - STARTED, - WAYPOINT, - ENDED, -}; - -//! An enum for character creation responses -enum eCreationResponse : uint8_t { - CREATION_RESPONSE_SUCCESS = 0, //!< The creation was successful - CREATION_RESPONSE_OBJECT_ID_UNAVAILABLE, //!< The Object ID can't be used - CREATION_RESPONSE_NAME_NOT_ALLOWED, //!< The name is not allowed - CREATION_RESPONSE_PREDEFINED_NAME_IN_USE, //!< The predefined name is already in use - CREATION_RESPONSE_CUSTOM_NAME_IN_USE //!< The custom name is already in use -}; - -//! An enum for login responses -enum eLoginResponse : uint8_t { - LOGIN_RESPONSE_GENERAL_FAILED = 0, - LOGIN_RESPONSE_SUCCESS = 1, - LOGIN_RESPONSE_BANNED = 2, - LOGIN_RESPONSE_PERMISSIONS_NOT_HIGH_ENOUGH = 5, - LOGIN_RESPONSE_WRONG_PASS_OR_USER = 6, - LOGIN_RESPONSE_ACCOUNT_LOCKED = 7 -}; - -//! An enum for character rename responses -enum eRenameResponse : uint8_t { - RENAME_RESPONSE_SUCCESS = 0, //!< The renaming was successful - RENAME_RESPONSE_UNKNOWN_ERROR, //!< There was an unknown error - RENAME_RESPONSE_NAME_UNAVAILABLE, //!< The name is unavailable - RENAME_RESPONSE_NAME_IN_USE //!< The name is already in use -}; - -//! A replica packet type -enum eReplicaPacketType { - PACKET_TYPE_CONSTRUCTION, //!< A construction packet - PACKET_TYPE_SERIALIZATION, //!< A serialization packet - PACKET_TYPE_DESTRUCTION //!< A destruction packet -}; - -//! The Behavior Types for use with the AI system -enum eCombatBehaviorTypes : uint32_t { - PASSIVE = 0, //!< The object is passive - AGGRESSIVE = 1, //!< The object is aggressive - PASSIVE_TURRET = 2, //!< The object is a passive turret - AGGRESSIVE_TURRET = 3 //!< The object is an aggressive turret -}; - -//! The Combat Role Type for use with the AI system -enum eCombatRoleType : uint32_t { - MELEE = 0, //!< Used for melee attacks - RANGED = 1, //!< Used for range attacks - SUPPORT = 2 //!< Used for support -}; - -//! The kill types for the Die packet -enum eKillType : uint32_t { - VIOLENT, - SILENT -}; - -//! The various world states used throughout the server -enum eObjectWorldState { - WORLDSTATE_INWORLD, //!< Probably used when the object is in the world - WORLDSTATE_ATTACHED, //!< Probably used when the object is attached to another object - WORLDSTATE_INVENTORY //!< Probably used when the object is in an inventory -}; - -//! The trigger stats (???) -enum eTriggerStat { - INVALID_STAT, //!< ??? - HEALTH, //!< Probably used for health - ARMOR, //!< Probably used for armor - IMAGINATION //!< Probably used for imagination -}; - -//! The trigger operations (???) -enum eTriggerOperator { - INVALID_OPER, //!< ??? - EQUAL, //!< ??? - NOT_EQUAL, //!< ??? - GREATER, //!< ??? - GREATER_EQUAL, //!< ??? - LESS, //!< ??? - LESS_EQUAL //!< ??? -}; - -//! The various build types -enum eBuildType { - BUILD_NOWHERE, //!< Used if something can't be built anywhere - BUILD_IN_WORLD, //!< Used if something can be built in the world - BUILD_ON_PROPERTY //!< Used if something can be build on a property -}; - -//! Quickbuild fail reasons -enum eFailReason : uint32_t { - REASON_NOT_GIVEN, - REASON_OUT_OF_IMAGINATION, - REASON_CANCELED_EARLY, - REASON_BUILD_ENDED -}; - -//! Terminate interaction type -enum eTerminateType : uint32_t { - RANGE, - USER, - FROM_INTERACTION -}; - -//! The combat state -enum eCombatState { - IDLE, //!< The AI is in an idle state - AGGRO, //!< The AI is in an aggressive state - TETHER, //!< The AI is being redrawn back to tether point - SPAWN, //!< The AI is spawning - DEAD //!< The AI is dead -}; - -enum eControlSceme { - SCHEME_A, - SCHEME_D, - SCHEME_GAMEPAD, - SCHEME_E, - SCHEME_FPS, - SCHEME_DRIVING, - SCHEME_TAMING, - SCHEME_MODULAR_BUILD, - SCHEME_WEAR_A_ROBOT //== freecam? -}; - -enum class eStateChangeType : uint32_t { - PUSH, - POP -}; - -enum eNotifyType { - NOTIFY_TYPE_SUCCESS, - NOTIFY_TYPE_QUIT, - NOTIFY_TYPE_FAILED, - NOTIFY_TYPE_BEGIN, - NOTIFY_TYPE_READY, - NOTIFY_TYPE_NAMINGPET -}; - - -enum class UseItemResponse : uint32_t { - NoImaginationForPet = 1, - FailedPrecondition, - MountsNotAllowed -}; - -enum eRebuildState : uint32_t { - REBUILD_OPEN, - REBUILD_COMPLETED = 2, - REBUILD_RESETTING = 4, - REBUILD_BUILDING, - REBUILD_INCOMPLETE -}; - -/** - * The loot source's type. - */ -enum eLootSourceType : int32_t { - LOOT_SOURCE_NONE = 0, - LOOT_SOURCE_CHEST, - LOOT_SOURCE_MISSION, - LOOT_SOURCE_MAIL, - LOOT_SOURCE_CURRENCY, - LOOT_SOURCE_ACHIEVEMENT, - LOOT_SOURCE_TRADE, - LOOT_SOURCE_QUICKBUILD, - LOOT_SOURCE_DELETION, - LOOT_SOURCE_VENDOR, - LOOT_SOURCE_ACTIVITY, - LOOT_SOURCE_PICKUP, - LOOT_SOURCE_BRICK, - LOOT_SOURCE_PROPERTY, - LOOT_SOURCE_MODERATION, - LOOT_SOURCE_EXHIBIT, - LOOT_SOURCE_INVENTORY, - LOOT_SOURCE_CLAIMCODE, - LOOT_SOURCE_CONSUMPTION, - LOOT_SOURCE_CRAFTING, - LOOT_SOURCE_LEVEL_REWARD, - LOOT_SOURCE_RELOCATE -}; - -enum eGameActivities : uint32_t { - ACTIVITY_NONE, - ACTIVITY_QUICKBUILDING, - ACTIVITY_SHOOTING_GALLERY, - ACTIVITY_RACING, - ACTIVITY_PINBALL, - ACTIVITY_PET_TAMING -}; - -enum ePlayerFlags { - BTARR_TESTING = 0, - PLAYER_HAS_ENTERED_PET_RANCH = 1, - MINIMAP_UNLOCKED = 2, - ACTIVITY_REBUILDING_FAIL_TIME = 3, - ACTIVITY_REBUILDING_FAIL_RANGE = 4, - ACTIVITY_SHOOTING_GALLERY_HELP = 5, - HELP_WALKING_CONTROLS = 6, - FIRST_SMASHABLE = 7, - FIRST_IMAGINATION_PICKUP = 8, - FIRST_DAMAGE = 9, - FIRST_ITEM = 10, - FIRST_BRICK = 11, - FIRST_CONSUMABLE = 12, - FIRST_EQUIPPABLE = 13, - CHAT_HELP = 14, - FIRST_PET_TAMING_MINIGAME = 15, - FIRST_PET_ON_SWITCH = 16, - FIRST_PET_JUMPED_ON_SWITCH = 17, - FIRST_PET_FOUND_TREASURE = 18, - FIRST_PET_DUG_TREASURE = 19, - FIRST_PET_OWNER_ON_PET_BOUNCER = 20, - FIRST_PET_DESPAWN_NO_IMAGINATION = 21, - FIRST_PET_SELECTED_ENOUGH_BRICKS = 22, - FIRST_EMOTE_UNLOCKED = 23, - GF_PIRATE_REP = 24, - AG_BOB_CINEMATIC_EVENT = 25, - HELP_JUMPING_CONTROLS = 26, - HELP_DOUBLE_JUMP_CONTROLS = 27, - HELP_CAMERA_CONTROLS = 28, - HELP_ROTATE_CONTROLS = 29, - HELP_SMASH = 30, - MONUMENT_INTRO_MUSIC_PLAYED = 31, - BEGINNING_ZONE_SUMMARY_DISPLAYED = 32, - AG_FINISH_LINE_BUILT = 33, - AG_BOSS_AREA_FOUND = 34, - AG_LANDED_IN_BATTLEFIELD = 35, - GF_PLAYER_HAS_BEEN_TO_THE_RAVINE = 36, - MODULAR_BUILD_STARTED = 37, - MODULAR_BUILD_FINISHED_CLICK_BUTTON = 38, - THINKING_HAT_RECEIVED_GO_TO_MODULAR_BUILD_AREA = 39, - BUILD_AREA_ENTERED_MOD_NOT_ACTIVATED_PUT_ON_HAT = 40, - HAT_ON_INSIDE_OF_MOD_BUILD_EQUIP_A_MODULE_FROM_LEG = 41, - MODULE_EQUIPPED_PLACE_ON_GLOWING_BLUE_SPOT = 42, - FIRST_MODULE_PLACED_CORRECTLY_NOW_DO_THE_REST = 43, - ROCKET_COMPLETE_NOW_LAUNCH_FROM_PAD = 44, - JOINED_A_FACTION = 45, - VENTURE_FACTION = 46, - ASSEMBLY_FACTION = 47, - PARADOX_FACTION = 48, - SENTINEL_FACTION = 49, - LUP_WORLD_ACCESS = 50, - AG_FIRST_FLAG_COLLECTED = 51, - TOOLTIP_TALK_TO_SKYLAND_TO_GET_HAT = 52, - MODULAR_BUILD_PLAYER_PLACES_FIRST_MODEL_IN_SCRATCH = 53, - MODULAR_BUILD_FIRST_ARROW_DISPLAY_FOR_MODULE = 54, - AG_BEACON_QB_SO_THE_PLAYER_CAN_ALWAYS_BUILD_THEM = 55, - GF_PET_DIG_FLAG_1 = 56, - GF_PET_DIG_FLAG_2 = 57, - GF_PET_DIG_FLAG_3 = 58, - SUPPRESS_SPACESHIP_CINEMATIC_FLYTHROUGH = 59, - GF_PLAYER_FALL_DEATH = 60, - GF_PLAYER_CAN_GET_FLAG_1 = 61, - GF_PLAYER_CAN_GET_FLAG_2 = 62, - GF_PLAYER_CAN_GET_FLAG_3 = 63, - ENTER_BBB_FROM_PROPERTY_EDIT_CONFIRMATION_DIALOG = 64, - AG_FIRST_COMBAT_COMPLETE = 65, - AG_COMPLETE_BOB_MISSION = 66, - IS_NEWS_SCREEN_VISIBLE = 114, - NJ_GARMADON_CINEMATIC_SEEN = 125, - ELEPHANT_PET_3050 = 801, - CAT_PET_3054 = 802, - TRICERATOPS_PET_3195 = 803, - TERRIER_PET_3254 = 804, - SKUNK_PET_3261 = 805, - LION_PET_3520 = 806, - BUNNY_PET_3672 = 807, - CROCODILE_PET_3994 = 808, - DOBERMAN_PET_5635 = 809, - BUFFALO_PET_5636 = 810, - ROBOT_DOG_PET_5637 = 811, - EUROPEAN_DRAGON_PET_5639 = 812, - TORTOISE_PET_5640 = 813, - ASIAN_DRAGON_PET_5641 = 814, - MANTIS_PET_5642 = 815, - PANDA_PET_5643 = 816, - WARTHOG_PET_6720 = 817, - GOAT_PET_7638 = 818, - CRAB_PET_7694 = 819, - AG_SPACE_SHIP_BINOC_AT_LAUNCH = 1001, - AG_SPACE_SHIP_BINOC_AT_LAUNCH_PLATFORM = 1002, - AG_SPACE_SHIP_BINOC_ON_PLATFORM_TO_LEFT_OF_START = 1003, - AG_SPACE_SHIP_BINOC_ON_PLATFORM_TO_RIGHT_OF_START = 1004, - AG_SPACE_SHIP_BINOC_AT_BOB = 1005, - AG_BATTLE_BINOC_FOR_TRICERETOPS = 1101, - AG_BATTLE_BINOC_AT_PARADOX = 1102, - AG_BATTLE_BINOC_AT_MISSION_GIVER = 1103, - AG_BATTLE_BINOC_AT_BECK = 1104, - AG_MONUMENT_BINOC_INTRO = 1105, - AG_MONUMENT_BINOC_OUTRO = 1106, - AG_LAUNCH_BINOC_INTRO = 1107, - AG_LAUNCH_BINOC_BISON = 1108, - AG_LAUNCH_BINOC_SHARK = 1109, - NS_BINOC_CONCERT_TRANSITION = 1201, - NS_BINOC_RACE_PLACE_TRANSITION = 1202, - NS_BINOC_BRICK_ANNEX_TRANSITION = 1203, - NS_BINOC_GF_LAUNCH = 1204, - NS_BINOC_FV_LAUNCH = 1205, - NS_BINOC_BRICK_ANNEX_WATER = 1206, - NS_BINOC_AG_LAUNCH_AT_RACE_PLACE = 1207, - NS_BINOC_AG_LAUNCH_AT_BRICK_ANNEX = 1208, - NS_BINOC_AG_LAUNCH_AT_PLAZA = 1209, - NS_BINOC_TBA = 1210, - NS_FLAG_COLLECTABLE_1_BY_JONNY_THUNDER = 1211, - NS_FLAG_COLLECTABLE_2_UNDER_CONCERT_BRIDGE = 1212, - NS_FLAG_COLLECTABLE_3_BY_FV_LAUNCH = 1213, - NS_FLAG_COLLECTABLE_4_IN_PLAZA_BEHIND_BUILDING = 1214, - NS_FLAG_COLLECTABLE_5_BY_GF_LAUNCH = 1215, - NS_FLAG_COLLECTABLE_6_BY_DUCK_SG = 1216, - NS_FLAG_COLLECTABLE_7_BY_LUP_LAUNCH = 1217, - NS_FLAG_COLLECTABLE_8_BY_NT_LUANCH = 1218, - NS_FLAG_COLLECTABLE_9_BY_RACE_BUILD = 1219, - NS_FLAG_COLLECTABLE_10_ON_AG_LAUNCH_PATH = 1220, - PR_BINOC_AT_LAUNCH_PAD = 1251, - PR_BINOC_AT_BEGINNING_OF_ISLAND_B = 1252, - PR_BINOC_AT_FIRST_PET_BOUNCER = 1253, - PR_BINOC_ON_BY_CROWS_NEST = 1254, - PR_PET_DIG_AT_BEGINNING_OF_ISLAND_B = 1261, - PR_PET_DIG_AT_THE_LOCATION_OF_OLD_BOUNCE_BACK = 1262, - PR_PET_DIG_UNDER_QB_BRIDGE = 1263, - PR_PET_DIG_BACK_SIDE_BY_PARTNER_BOUNCE = 1264, - PR_PET_DIG_BY_LAUNCH_PAD = 1265, - PR_PET_DIG_BY_FIRST_PET_BOUNCER = 1266, - GF_BINOC_ON_LANDING_PAD = 1301, - GF_BINOC_AT_RAVINE_START = 1302, - GF_BINOC_ON_TOP_OF_RAVINE_HEAD = 1303, - GF_BINOC_AT_TURTLE_AREA = 1304, - GF_BINOC_IN_TUNNEL_TO_ELEPHANTS = 1305, - GF_BINOC_IN_ELEPHANTS_AREA = 1306, - GF_BINOC_IN_RACING_AREA = 1307, - GF_BINOC_IN_CROC_AREA = 1308, - GF_BINOC_IN_JAIL_AREA = 1309, - GF_BINOC_TELESCOPE_NEXT_TO_CAPTAIN_JACK = 1310, - NT_PLINTH_REBUILD = 1919, - NT_FACTION_SPY_DUKE = 1974, - NT_FACTION_SPY_OVERBUILD = 1976, - NT_FACTION_SPY_HAEL = 1977, - NJ_EARTH_SPINJITZU = 2030, - NJ_LIGHTNING_SPINJITZU = 2031, - NJ_ICE_SPINJITZU = 2032, - NJ_FIRE_SPINJITZU = 2033, - NJ_WU_SHOW_DAILY_CHEST = 2099 -}; - -//======== FUNC =========== - -template -inline T const& clamp(const T& val, const T& low, const T& high) { - if (val < low) return low; - else if (val > high) return high; - - return val; -} - #endif //!__DCOMMONVARS__H__ diff --git a/dCommon/dEnums/dMessageIdentifiers.h b/dCommon/dEnums/dMessageIdentifiers.h deleted file mode 100644 index 7c810a2d..00000000 --- a/dCommon/dEnums/dMessageIdentifiers.h +++ /dev/null @@ -1,564 +0,0 @@ -#pragma once -#include "MessageIdentifiers.h" - -enum CONNECTION_TYPE { - SERVER = 0, //!< Means it is used throughout all servers - AUTH, //!< Means it is sent from the client authentication - CHAT, //!< Means it is sent from and to the chat server - CHAT_INTERNAL, //!< Unused - We can potentially use this in the future for various things - WORLD, //!< Means it is sent from the client world - CLIENT, //!< Means it is sent to the client from the world server - MASTER //!< Means it is sent to and from the master server -}; - -//! The Internal Server Packet Identifiers -enum SERVER { - MSG_SERVER_VERSION_CONFIRM = 0, /*!< Sent during a handshake to confirm the server/client version */ - MSG_SERVER_DISCONNECT_NOTIFY, /*!< Sent when a user disconnected */ - MSG_SERVER_GENERAL_NOTIFY /*!< A general notification */ -}; - -//! The Internal Authentication Packet Identifiers -enum AUTH { - MSG_AUTH_LOGIN_REQUEST = 0, /*!< Sent from the client when a user logs in */ - MSG_AUTH_LOGOUT_REQUEST, /*!< Sent from the client when a user logs out */ - MSG_AUTH_CREATE_NEW_ACCOUNT_REQUEST, /*!< Sent from the client when a user creates a new account */ - MSG_AUTH_LEGOINTERFACE_AUTH_RESPONSE, /*!< Unknown */ - MSG_AUTH_SESSIONKEY_RECEIVED_CONFIRM, /*!< Sent when the server recieved the session key (?) */ - MSG_AUTH_RUNTIME_CONFIG /*!< Unknown */ -}; - -//! The Internal Chat Packet Identifiers -enum CHAT { - MSG_CHAT_LOGIN_SESSION_NOTIFY = 0, /*!< When a user logs in */ - MSG_CHAT_GENERAL_CHAT_MESSAGE, /*!< Used for global chat messages */ - MSG_CHAT_PRIVATE_CHAT_MESSAGE, /*!< Used for private chat messages */ - MSG_CHAT_USER_CHANNEL_CHAT_MESSAGE, /*!< Unknown */ - MSG_CHAT_WORLD_DISCONNECT_REQUEST, /*!< Unknown */ - MSG_CHAT_WORLD_PROXIMITY_RESPONSE, /*!< Unknown */ - MSG_CHAT_WORLD_PARCEL_RESPONSE, /*!< Unknown */ - MSG_CHAT_ADD_FRIEND_REQUEST, /*!< When the client requests to add a friend */ - MSG_CHAT_ADD_FRIEND_RESPONSE, /*!< Sent from the server when the client adds a friend */ - MSG_CHAT_REMOVE_FRIEND, /*!< When the client removes a friend */ - MSG_CHAT_GET_FRIENDS_LIST, /*!< Sent when the client requests a user's friends list */ - MSG_CHAT_ADD_IGNORE, /*!< Sent when the client adds a friend to the "ignore" list */ - MSG_CHAT_REMOVE_IGNORE, /*!< Sent when the client removes a friend from the "ignore" list */ - MSG_CHAT_GET_IGNORE_LIST, /*!< Sent when the client requests a user's ignored list */ - MSG_CHAT_TEAM_MISSED_INVITE_CHECK, /*!< Unknown (Something with an unresponded-to friend request probably) */ - MSG_CHAT_TEAM_INVITE, /*!< When the client invites a user to a team */ - MSG_CHAT_TEAM_INVITE_RESPONSE, /*!< Sent from the server when the client invites someone to the team */ - MSG_CHAT_TEAM_KICK, /*!< Sent when the client kicks a member from a team */ - MSG_CHAT_TEAM_LEAVE, /*!< Sent when the client leaves a team */ - MSG_CHAT_TEAM_SET_LOOT, /*!< Unknown (Something to do with team loot) */ - MSG_CHAT_TEAM_SET_LEADER, /*!< Unknown (Probably sets the team leader or something) */ - MSG_CHAT_TEAM_GET_STATUS, /*!< Check to see if we are in a team or not, sent on world join */ - MSG_CHAT_GUILD_CREATE, /*!< Guild Creation */ - MSG_CHAT_GUILD_INVITE, /*!< Guild Invitation */ - MSG_CHAT_GUILD_INVITE_RESPONSE, /*!< Guild Invite Response */ - MSG_CHAT_GUILD_LEAVE, /*!< Guild Leave */ - MSG_CHAT_GUILD_KICK, /*!< Guild Kick */ - MSG_CHAT_GUILD_GET_STATUS, /*!< Guild Get Status */ - MSG_CHAT_GUILD_GET_ALL, /*!< Guild Get All */ - MSG_CHAT_SHOW_ALL, - MSG_CHAT_BLUEPRINT_MODERATED, - MSG_CHAT_BLUEPRINT_MODEL_READY, - MSG_CHAT_PROPERTY_READY_FOR_APPROVAL, - MSG_CHAT_PROPERTY_MODERATION_CHANGED, - MSG_CHAT_PROPERTY_BUILDMODE_CHANGED, - MSG_CHAT_PROPERTY_BUILDMODE_CHANGED_REPORT, - MSG_CHAT_MAIL, - MSG_CHAT_WORLD_INSTANCE_LOCATION_REQUEST, - MSG_CHAT_REPUTATION_UPDATE, - MSG_CHAT_SEND_CANNED_TEXT, - MSG_CHAT_GMLEVEL_UPDATE, - MSG_CHAT_CHARACTER_NAME_CHANGE_REQUEST, - MSG_CHAT_CSR_REQUEST, - MSG_CHAT_CSR_REPLY, - MSG_CHAT_GM_KICK, - MSG_CHAT_GM_ANNOUNCE, - MSG_CHAT_GM_MUTE, - MSG_CHAT_ACTIVITY_UPDATE, - MSG_CHAT_WORLD_ROUTE_PACKET, - MSG_CHAT_GET_ZONE_POPULATIONS, - MSG_CHAT_REQUEST_MINIMUM_CHAT_MODE, - MSG_CHAT_REQUEST_MINIMUM_CHAT_MODE_PRIVATE, - MSG_CHAT_MATCH_REQUEST, - MSG_CHAT_UGCMANIFEST_REPORT_MISSING_FILE, - MSG_CHAT_UGCMANIFEST_REPORT_DONE_FILE, - MSG_CHAT_UGCMANIFEST_REPORT_DONE_BLUEPRINT, - MSG_CHAT_UGCC_REQUEST, - MSG_CHAT_WHO, - MSG_CHAT_WORLD_PLAYERS_PET_MODERATED_ACKNOWLEDGE, - MSG_CHAT_ACHIEVEMENT_NOTIFY, - MSG_CHAT_GM_CLOSE_PRIVATE_CHAT_WINDOW, - MSG_CHAT_UNEXPECTED_DISCONNECT, - MSG_CHAT_PLAYER_READY, - MSG_CHAT_GET_DONATION_TOTAL, - MSG_CHAT_UPDATE_DONATION, - MSG_CHAT_PRG_CSR_COMMAND, - MSG_CHAT_HEARTBEAT_REQUEST_FROM_WORLD, - MSG_CHAT_UPDATE_FREE_TRIAL_STATUS -}; - -//! Used for packets related to chatting -enum CHAT_INTERNAL { - MSG_CHAT_INTERNAL_PLAYER_ADDED_NOTIFICATION = 0, - MSG_CHAT_INTERNAL_PLAYER_REMOVED_NOTIFICATION, - MSG_CHAT_INTERNAL_ADD_FRIEND, - MSG_CHAT_INTERNAL_ADD_BEST_FRIEND, - MSG_CHAT_INTERNAL_ADD_TO_TEAM, - MSG_CHAT_INTERNAL_ADD_BLOCK, - MSG_CHAT_INTERNAL_REMOVE_FRIEND, - MSG_CHAT_INTERNAL_REMOVE_BLOCK, - MSG_CHAT_INTERNAL_REMOVE_FROM_TEAM, - MSG_CHAT_INTERNAL_DELETE_TEAM, - MSG_CHAT_INTERNAL_REPORT, - MSG_CHAT_INTERNAL_PRIVATE_CHAT, - MSG_CHAT_INTERNAL_PRIVATE_CHAT_RESPONSE, - MSG_CHAT_INTERNAL_ANNOUNCEMENT, - MSG_CHAT_INTERNAL_MAIL_COUNT_UPDATE, - MSG_CHAT_INTERNAL_MAIL_SEND_NOTIFY, - MSG_CHAT_INTERNAL_REQUEST_USER_LIST, - MSG_CHAT_INTERNAL_FRIEND_LIST, - MSG_CHAT_INTERNAL_ROUTE_TO_PLAYER, - MSG_CHAT_INTERNAL_TEAM_UPDATE, - MSG_CHAT_INTERNAL_MUTE_UPDATE, - MSG_CHAT_INTERNAL_CREATE_TEAM, -}; - -//! Used for packets send to the world -enum WORLD { - MSG_WORLD_CLIENT_VALIDATION = 1, // Session info - MSG_WORLD_CLIENT_CHARACTER_LIST_REQUEST, - MSG_WORLD_CLIENT_CHARACTER_CREATE_REQUEST, - MSG_WORLD_CLIENT_LOGIN_REQUEST, // Character selected - MSG_WORLD_CLIENT_GAME_MSG, - MSG_WORLD_CLIENT_CHARACTER_DELETE_REQUEST, - MSG_WORLD_CLIENT_CHARACTER_RENAME_REQUEST, - MSG_WORLD_CLIENT_HAPPY_FLOWER_MODE_NOTIFY, - MSG_WORLD_CLIENT_SLASH_RELOAD_MAP, // Reload map cmp - MSG_WORLD_CLIENT_SLASH_PUSH_MAP_REQUEST, // Push map req cmd - MSG_WORLD_CLIENT_SLASH_PUSH_MAP, // Push map cmd - MSG_WORLD_CLIENT_SLASH_PULL_MAP, // Pull map cmd - MSG_WORLD_CLIENT_LOCK_MAP_REQUEST, - MSG_WORLD_CLIENT_GENERAL_CHAT_MESSAGE, // General chat message - MSG_WORLD_CLIENT_HTTP_MONITOR_INFO_REQUEST, - MSG_WORLD_CLIENT_SLASH_DEBUG_SCRIPTS, // Debug scripts cmd - MSG_WORLD_CLIENT_MODELS_CLEAR, - MSG_WORLD_CLIENT_EXHIBIT_INSERT_MODEL, - MSG_WORLD_CLIENT_LEVEL_LOAD_COMPLETE, // Character data request - MSG_WORLD_CLIENT_TMP_GUILD_CREATE, - MSG_WORLD_CLIENT_ROUTE_PACKET, // Social? - MSG_WORLD_CLIENT_POSITION_UPDATE, - MSG_WORLD_CLIENT_MAIL, - MSG_WORLD_CLIENT_WORD_CHECK, // Whitelist word check - MSG_WORLD_CLIENT_STRING_CHECK, // Whitelist string check - MSG_WORLD_CLIENT_GET_PLAYERS_IN_ZONE, - MSG_WORLD_CLIENT_REQUEST_UGC_MANIFEST_INFO, - MSG_WORLD_CLIENT_BLUEPRINT_GET_ALL_DATA_REQUEST, - MSG_WORLD_CLIENT_CANCEL_MAP_QUEUE, - MSG_WORLD_CLIENT_HANDLE_FUNNESS, - MSG_WORLD_CLIENT_FAKE_PRG_CSR_MESSAGE, - MSG_WORLD_CLIENT_REQUEST_FREE_TRIAL_REFRESH, - MSG_WORLD_CLIENT_GM_SET_FREE_TRIAL_STATUS -}; - -//! An enum for packets sent to the client -enum CLIENT { - MSG_CLIENT_LOGIN_RESPONSE = 0, - MSG_CLIENT_LOGOUT_RESPONSE, - MSG_CLIENT_LOAD_STATIC_ZONE, - MSG_CLIENT_CREATE_OBJECT, - MSG_CLIENT_CREATE_CHARACTER, - MSG_CLIENT_CREATE_CHARACTER_EXTENDED, - MSG_CLIENT_CHARACTER_LIST_RESPONSE, - MSG_CLIENT_CHARACTER_CREATE_RESPONSE, - MSG_CLIENT_CHARACTER_RENAME_RESPONSE, - MSG_CLIENT_CHAT_CONNECT_RESPONSE, - MSG_CLIENT_AUTH_ACCOUNT_CREATE_RESPONSE, - MSG_CLIENT_DELETE_CHARACTER_RESPONSE, - MSG_CLIENT_GAME_MSG, - MSG_CLIENT_CONNECT_CHAT, - MSG_CLIENT_TRANSFER_TO_WORLD, - MSG_CLIENT_IMPENDING_RELOAD_NOTIFY, - MSG_CLIENT_MAKE_GM_RESPONSE, - MSG_CLIENT_HTTP_MONITOR_INFO_RESPONSE, - MSG_CLIENT_SLASH_PUSH_MAP_RESPONSE, - MSG_CLIENT_SLASH_PULL_MAP_RESPONSE, - MSG_CLIENT_SLASH_LOCK_MAP_RESPONSE, - MSG_CLIENT_BLUEPRINT_SAVE_RESPONSE, - MSG_CLIENT_BLUEPRINT_LUP_SAVE_RESPONSE, - MSG_CLIENT_BLUEPRINT_LOAD_RESPONSE_ITEMID, - MSG_CLIENT_BLUEPRINT_GET_ALL_DATA_RESPONSE, - MSG_CLIENT_MODEL_INSTANTIATE_RESPONSE, - MSG_CLIENT_DEBUG_OUTPUT, - MSG_CLIENT_ADD_FRIEND_REQUEST, - MSG_CLIENT_ADD_FRIEND_RESPONSE, - MSG_CLIENT_REMOVE_FRIEND_RESPONSE, - MSG_CLIENT_GET_FRIENDS_LIST_RESPONSE, - MSG_CLIENT_UPDATE_FRIEND_NOTIFY, - MSG_CLIENT_ADD_IGNORE_RESPONSE, - MSG_CLIENT_REMOVE_IGNORE_RESPONSE, - MSG_CLIENT_GET_IGNORE_LIST_RESPONSE, - MSG_CLIENT_TEAM_INVITE, - MSG_CLIENT_TEAM_INVITE_INITIAL_RESPONSE, - MSG_CLIENT_GUILD_CREATE_RESPONSE, - MSG_CLIENT_GUILD_GET_STATUS_RESPONSE, - MSG_CLIENT_GUILD_INVITE, - MSG_CLIENT_GUILD_INVITE_INITIAL_RESPONSE, - MSG_CLIENT_GUILD_INVITE_FINAL_RESPONSE, - MSG_CLIENT_GUILD_INVITE_CONFIRM, - MSG_CLIENT_GUILD_ADD_PLAYER, - MSG_CLIENT_GUILD_REMOVE_PLAYER, - MSG_CLIENT_GUILD_LOGIN_LOGOUT, - MSG_CLIENT_GUILD_RANK_CHANGE, - MSG_CLIENT_GUILD_DATA, - MSG_CLIENT_GUILD_STATUS, - MSG_CLIENT_MAIL, - MSG_CLIENT_DB_PROXY_RESULT, - MSG_CLIENT_SHOW_ALL_RESPONSE, - MSG_CLIENT_WHO_RESPONSE, - MSG_CLIENT_SEND_CANNED_TEXT, - MSG_CLIENT_UPDATE_CHARACTER_NAME, - MSG_CLIENT_SET_NETWORK_SIMULATOR, - MSG_CLIENT_INVALID_CHAT_MESSAGE, - MSG_CLIENT_MINIMUM_CHAT_MODE_RESPONSE, - MSG_CLIENT_MINIMUM_CHAT_MODE_RESPONSE_PRIVATE, - MSG_CLIENT_CHAT_MODERATION_STRING, - MSG_CLIENT_UGC_MANIFEST_RESPONSE, - MSG_CLIENT_IN_LOGIN_QUEUE, - MSG_CLIENT_SERVER_STATES, - MSG_CLIENT_GM_CLOSE_TARGET_CHAT_WINDOW, - MSG_CLIENT_GENERAL_TEXT_FOR_LOCALIZATION, - MSG_CLIENT_UPDATE_FREE_TRIAL_STATUS, - MSG_CLIENT_UGC_DOWNLOAD_FAILED = 120 -}; - -//! Used for packets sent to the master server -enum MASTER { - MSG_MASTER_REQUEST_PERSISTENT_ID = 1, - MSG_MASTER_REQUEST_PERSISTENT_ID_RESPONSE, - MSG_MASTER_REQUEST_ZONE_TRANSFER, - MSG_MASTER_REQUEST_ZONE_TRANSFER_RESPONSE, - MSG_MASTER_SERVER_INFO, - MSG_MASTER_REQUEST_SESSION_KEY, - MSG_MASTER_SET_SESSION_KEY, - MSG_MASTER_SESSION_KEY_RESPONSE, - MSG_MASTER_PLAYER_ADDED, - MSG_MASTER_PLAYER_REMOVED, - - MSG_MASTER_CREATE_PRIVATE_ZONE, - MSG_MASTER_REQUEST_PRIVATE_ZONE, - - MSG_MASTER_WORLD_READY, - MSG_MASTER_PREP_ZONE, - - MSG_MASTER_SHUTDOWN, - MSG_MASTER_SHUTDOWN_RESPONSE, - MSG_MASTER_SHUTDOWN_IMMEDIATE, - - MSG_MASTER_SHUTDOWN_UNIVERSE, - - MSG_MASTER_AFFIRM_TRANSFER_REQUEST, - MSG_MASTER_AFFIRM_TRANSFER_RESPONSE, - - MSG_MASTER_NEW_SESSION_ALERT -}; - -//! The Game messages -enum GAME_MSG : unsigned short { - GAME_MSG_TELEPORT = 19, - GAME_MSG_SET_PLAYER_CONTROL_SCHEME = 26, - GAME_MSG_DROP_CLIENT_LOOT = 30, - GAME_MSG_DIE = 37, - GAME_MSG_REQUEST_DIE = 38, - GAME_MSG_PLAY_EMOTE = 41, - GAME_MSG_PLAY_ANIMATION = 43, - GAME_MSG_CONTROL_BEHAVIOR = 48, - GAME_MSG_SET_NAME = 72, - GAME_MSG_ECHO_START_SKILL = 118, - GAME_MSG_START_SKILL = 119, - GAME_MSG_VERIFY_ACK = 121, - GAME_MSG_ADD_SKILL = 127, - GAME_MSG_REMOVE_SKILL = 128, - GAME_MSG_SET_CURRENCY = 133, - GAME_MSG_PICKUP_CURRENCY = 137, - GAME_MSG_PICKUP_ITEM = 139, - GAME_MSG_TEAM_PICKUP_ITEM = 140, - GAME_MSG_PLAY_FX_EFFECT = 154, - GAME_MSG_STOP_FX_EFFECT = 155, - GAME_MSG_REQUEST_RESURRECT = 159, - GAME_MSG_RESURRECT = 160, - GAME_MSG_PUSH_EQUIPPED_ITEMS_STATE = 191, - GAME_MSG_POP_EQUIPPED_ITEMS_STATE = 192, - GAME_MSG_SET_GM_LEVEL = 193, - GAME_MSG_SET_STUNNED = 198, - GAME_MSG_SET_STUN_IMMUNITY = 200, - GAME_MSG_KNOCKBACK = 202, - GAME_MSG_REBUILD_CANCEL = 209, - GAME_MSG_ENABLE_REBUILD = 213, - GAME_MSG_MOVE_ITEM_IN_INVENTORY = 224, - GAME_MSG_ADD_ITEM_TO_INVENTORY_CLIENT_SYNC = 227, - GAME_MSG_REMOVE_ITEM_FROM_INVENTORY = 230, - GAME_MSG_EQUIP_ITEM = 231, - GAME_MSG_UN_EQUIP_ITEM = 233, - GAME_MSG_OFFER_MISSION = 248, - GAME_MSG_RESPOND_TO_MISSION = 249, - GAME_MSG_NOTIFY_MISSION = 254, - GAME_MSG_NOTIFY_MISSION_TASK = 255, - GAME_MSG_REBUILD_NOTIFY_STATE = 336, - GAME_MSG_TERMINATE_INTERACTION = 357, - GAME_MSG_SERVER_TERMINATE_INTERACTION = 358, - GAME_MSG_REQUEST_USE = 364, - GAME_MSG_VENDOR_OPEN_WINDOW = 369, - GAME_MSG_BUY_FROM_VENDOR = 373, - GAME_MSG_SELL_TO_VENDOR = 374, - GAME_MSG_TEAM_SET_OFF_WORLD_FLAG = 383, - GAME_MSG_SET_INVENTORY_SIZE = 389, - GAME_MSG_ACKNOWLEDGE_POSSESSION = 391, - GAME_MSG_SET_SHOOTING_GALLERY_PARAMS = 400, - GAME_MSG_REQUEST_ACTIVITY_START_STOP = 402, - GAME_MSG_REQUEST_ACTIVITY_ENTER = 403, - GAME_MSG_REQUEST_ACTIVITY_EXIT = 404, - GAME_MSG_ACTIVITY_ENTER = 405, - GAME_MSG_ACTIVITY_EXIT = 406, - GAME_MSG_ACTIVITY_START = 407, - GAME_MSG_ACTIVITY_STOP = 408, - GAME_MSG_SHOOTING_GALLERY_CLIENT_AIM_UPDATE = 409, - GAME_MSG_SHOOTING_GALLERY_FIRE = 411, - GAME_MSG_REQUEST_VENDOR_STATUS_UPDATE = 416, - GAME_MSG_VENDOR_STATUS_UPDATE = 417, - GAME_MSG_NOTIFY_CLIENT_SHOOTING_GALLERY_SCORE = 425, - GAME_MSG_CONSUME_CLIENT_ITEM = 427, - GAME_MSG_CLIENT_ITEM_CONSUMED = 428, - GAME_MSG_UPDATE_SHOOTING_GALLERY_ROTATION = 448, - GAME_MSG_SET_FLAG = 471, - GAME_MSG_NOTIFY_CLIENT_FLAG_CHANGE = 472, - GAME_MSG_VENDOR_TRANSACTION_RESULT = 476, - GAME_MSG_HAS_BEEN_COLLECTED = 486, - GAME_MSG_DISPLAY_CHAT_BUBBLE = 495, - GAME_MSG_SPAWN_PET = 498, - GAME_MSG_DESPAWN_PET = 499, - GAME_MSG_PLAYER_LOADED = 505, - GAME_MSG_PLAYER_READY = 509, - GAME_MSG_REQUEST_LINKED_MISSION = 515, - GAME_MSG_INVALID_ZONE_TRANSFER_LIST = 519, - GAME_MSG_MISSION_DIALOGUE_OK = 520, - GAME_MSG_DISPLAY_MESSAGE_BOX = 529, - GAME_MSG_MESSAGE_BOX_RESPOND = 530, - GAME_MSG_CHOICE_BOX_RESPOND = 531, - GAME_MSG_SMASH = 537, - GAME_MSG_UNSMASH = 538, - GAME_MSG_SET_SHOOTING_GALLERY_RETICULE_EFFECT = 548, - GAME_MSG_PLACE_MODEL_RESPONSE = 0x223, - GAME_MSG_SET_JET_PACK_MODE = 561, - GAME_MSG_REGISTER_PET_ID = 565, - GAME_MSG_REGISTER_PET_DBID = 566, - GAME_MSG_SHOW_ACTIVITY_COUNTDOWN = 568, - GAME_MSG_START_ACTIVITY_TIME = 576, - GAME_MSG_ACTIVITY_PAUSE = 602, - GAME_MSG_USE_NON_EQUIPMENT_ITEM = 603, - GAME_MSG_USE_ITEM_RESULT = 607, - GAME_MSG_COMMAND_PET = 640, - GAME_MSG_PET_RESPONSE = 641, - GAME_MSG_REQUEST_ACTIVITY_SUMMARY_LEADERBOARD_DATA = 648, - GAME_MSG_SEND_ACTIVITY_SUMMARY_LEADERBOARD_DATA = 649, - GAME_MSG_NOTIFY_OBJECT = 656, - GAME_MSG_CLIENT_NOTIFY_PET = 659, - GAME_MSG_NOTIFY_PET = 660, - GAME_MSG_NOTIFY_PET_TAMING_MINIGAME = 661, - GAME_MSG_START_SERVER_PET_MINIGAME_TIMER = 662, - GAME_MSG_CLIENT_EXIT_TAMING_MINIGAME = 663, - GAME_MSG_PET_NAME_CHANGED = 686, - GAME_MSG_PET_TAMING_MINIGAME_RESULT = 667, - GAME_MSG_PET_TAMING_TRY_BUILD_RESULT = 668, - GAME_MSG_NOTIFY_TAMING_BUILD_SUCCESS = 673, - GAME_MSG_NOTIFY_TAMING_MODEL_LOADED_ON_SERVER = 674, - GAME_MSG_ACTIVATE_BUBBLE_BUFF = 678, - GAME_MSG_DEACTIVATE_BUBBLE_BUFF = 679, - GAME_MSG_ADD_PET_TO_PLAYER = 681, - GAME_MSG_REQUEST_SET_PET_NAME = 683, - GAME_MSG_SET_PET_NAME = 684, - GAME_MSG_NOTIFY_PET_TAMING_PUZZLE_SELECTED = 675, - GAME_MSG_SHOW_PET_ACTION_BUTTON = 692, - GAME_MSG_SET_EMOTE_LOCK_STATE = 693, - GAME_MSG_USE_ITEM_REQUIREMENTS_RESPONSE = 703, - GAME_MSG_PLAY_EMBEDDED_EFFECT_ON_ALL_CLIENTS_NEAR_OBJECT = 713, - GAME_MSG_DOWNLOAD_PROPERTY_DATA = 716, - GAME_MSG_QUERY_PROPERTY_DATA = 717, - GAME_MSG_PROPERTY_EDITOR_BEGIN = 724, - GAME_MSG_PROPERTY_EDITOR_END = 725, - GAME_MSG_IS_MINIFIG_IN_A_BUBBLE = 729, - GAME_MSG_START_PATHING = 733, - GAME_MSG_ACTIVATE_BUBBLE_BUFF_FROM_SERVER = 734, - GAME_MSG_DEACTIVATE_BUBBLE_BUFF_FROM_SERVER = 735, - GAME_MSG_NOTIFY_CLIENT_ZONE_OBJECT = 737, - GAME_MSG_UPDATE_REPUTATION = 746, - GAME_MSG_PROPERTY_RENTAL_RESPONSE = 750, - GAME_MSG_REQUEST_PLATFORM_RESYNC = 760, - GAME_MSG_PLATFORM_RESYNC = 761, - GAME_MSG_PLAY_CINEMATIC = 762, - GAME_MSG_END_CINEMATIC = 763, - GAME_MSG_CINEMATIC_UPDATE = 764, - GAME_MSG_TOGGLE_GHOST_REFERENCE_OVERRIDE = 767, - GAME_MSG_SET_GHOST_REFERENCE_POSITION = 768, - GAME_MSG_FIRE_EVENT_SERVER_SIDE = 770, - GAME_MSG_SET_NETWORK_SCRIPT_VAR = 781, - GAME_MSG_UPDATE_MODEL_FROM_CLIENT = 793, - GAME_MSG_DELETE_MODEL_FROM_CLIENT = 794, - GAME_MSG_PLAY_ND_AUDIO_EMITTER = 821, - GAME_MSG_PLAY2_DAMBIENT_SOUND = 831, - GAME_MSG_ENTER_PROPERTY1 = 840, - GAME_MSG_ENTER_PROPERTY2 = 841, - GAME_MSG_PROPERTY_ENTRANCE_SYNC = 842, - GAME_MSG_PROPERTY_SELECT_QUERY = 845, - GAME_MSG_PARSE_CHAT_MESSAGE = 850, - GAME_MSG_BROADCAST_TEXT_TO_CHATBOX = 858, - GAME_MSG_OPEN_PROPERTY_MANAGEMENT = 860, - GAME_MSG_OPEN_PROPERTY_VENDOR = 861, - GAME_MSG_UPDATE_PROPERTY_OR_MODEL_FOR_FILTER_CHECK = 863, - GAME_MSG_CLIENT_TRADE_REQUEST = 868, - GAME_MSG_SERVER_TRADE_REQUEST = 869, - GAME_MSG_SERVER_TRADE_INVITE = 870, - GAME_MSG_CLIENT_TRADE_REPLY = 871, - GAME_MSG_SERVER_TRADE_REPLY = 872, - GAME_MSG_SERVER_TRADE_INITIAL_REPLY = 873, - GAME_MSG_SERVER_TRADE_FINAL_REPLY = 874, - GAME_MSG_CLIENT_TRADE_UPDATE = 875, - GAME_MSG_SERVER_SIDE_TRADE_UPDATE = 876, - GAME_MSG_SERVER_TRADE_UPDATE = 877, - GAME_MSG_CLIENT_TRADE_CANCEL = 878, - GAME_MSG_CLIENT_SIDE_TRADE_CANCEL = 879, - GAME_MSG_CLIENT_TRADE_ACCEPT = 880, - GAME_MSG_SERVER_SIDE_TRADE_ACCEPT = 881, - GAME_MSG_SERVER_SIDE_TRADE_CANCEL = 882, - GAME_MSG_SERVER_TRADE_CANCEL = 883, - GAME_MSG_SERVER_TRADE_ACCEPT = 884, - GAME_MSG_READY_FOR_UPDATES = 888, - GAME_MSG_ORIENT_TO_OBJECT = 905, - GAME_MSG_ORIENT_TO_POSITION = 906, - GAME_MSG_ORIENT_TO_ANGLE = 907, - GAME_MSG_BOUNCER_ACTIVE_STATUS = 942, - GAME_MSG_UN_USE_BBB_MODEL = 999, - GAME_MSG_BBB_LOAD_ITEM_REQUEST = 1000, - GAME_MSG_BBB_SAVE_REQUEST = 1001, - GAME_MSG_BBB_SAVE_RESPONSE = 1006, - GAME_MSG_NOTIFY_CLIENT_OBJECT = 1042, - GAME_MSG_DISPLAY_ZONE_SUMMARY = 1043, - GAME_MSG_ZONE_SUMMARY_DISMISSED = 1044, - GAME_MSG_ACTIVITY_STATE_CHANGE_REQUEST = 1053, - GAME_MSG_MODIFY_PLAYER_ZONE_STATISTIC = 1046, - GAME_MSG_START_BUILDING_WITH_ITEM = 1057, - GAME_MSG_START_ARRANGING_WITH_ITEM = 1061, - GAME_MSG_FINISH_ARRANGING_WITH_ITEM = 1062, - GAME_MSG_DONE_ARRANGING_WITH_ITEM = 1063, - GAME_MSG_SET_BUILD_MODE = 1068, - GAME_MSG_BUILD_MODE_SET = 1069, - GAME_MSG_SET_BUILD_MODE_CONFIRMED = 1073, - GAME_MSG_NOTIFY_CLIENT_FAILED_PRECONDITION = 1081, - GAME_MSG_MOVE_ITEM_BETWEEN_INVENTORY_TYPES = 1093, - GAME_MSG_MODULAR_BUILD_BEGIN = 1094, - GAME_MSG_MODULAR_BUILD_END = 1095, - GAME_MSG_MODULAR_BUILD_MOVE_AND_EQUIP = 1096, - GAME_MSG_MODULAR_BUILD_FINISH = 1097, - GAME_MSG_REPORT_BUG = 1198, - GAME_MSG_MISSION_DIALOGUE_CANCELLED = 1129, - GAME_MSG_ECHO_SYNC_SKILL = 1144, - GAME_MSG_SYNC_SKILL = 1145, - GAME_MSG_REQUEST_SERVER_PROJECTILE_IMPACT = 1148, - GAME_MSG_DO_CLIENT_PROJECTILE_IMPACT = 1151, - GAME_MSG_MODULAR_BUILD_CONVERT_MODEL = 1155, - GAME_MSG_SET_PLAYER_ALLOWED_RESPAWN = 1165, - GAME_MSG_UI_MESSAGE_SERVER_TO_SINGLE_CLIENT = 1184, - GAME_MSG_UI_MESSAGE_SERVER_TO_ALL_CLIENTS = 1185, - GAME_MSG_PET_TAMING_TRY_BUILD = 1197, - GAME_MSG_REQUEST_SMASH_PLAYER = 1202, - GAME_MSG_FIRE_EVENT_CLIENT_SIDE = 1213, - GAME_MSG_TOGGLE_GM_INVIS = 1218, - GAME_MSG_CHANGE_OBJECT_WORLD_STATE = 1223, - GAME_MSG_VEHICLE_LOCK_INPUT = 1230, - GAME_MSG_VEHICLE_UNLOCK_INPUT = 1231, - GAME_MSG_RACING_RESET_PLAYER_TO_LAST_RESET = 1252, - GAME_MSG_RACING_SERVER_SET_PLAYER_LAP_AND_PLANE = 1253, - GAME_MSG_RACING_SET_PLAYER_RESET_INFO = 1254, - GAME_MSG_RACING_PLAYER_INFO_RESET_FINISHED = 1255, - GAME_MSG_LOCK_NODE_ROTATION = 1260, - GAME_MSG_VEHICLE_SET_WHEEL_LOCK_STATE = 1273, - GAME_MSG_NOTIFY_VEHICLE_OF_RACING_OBJECT = 1276, - GAME_MSG_SET_NAME_BILLBOARD_STATE = 1284, - GAME_MSG_PLAYER_REACHED_RESPAWN_CHECKPOINT = 1296, - GAME_MSG_HANDLE_UGC_EQUIP_POST_DELETE_BASED_ON_EDIT_MODE = 1300, - GAME_MSG_HANDLE_UGC_EQUIP_PRE_CREATE_BASED_ON_EDIT_MODE = 1301, - GAME_MSG_PROPERTY_CONTENTS_FROM_CLIENT = 1305, - GAME_MSG_GET_MODELS_ON_PROPERTY = 1306, - GAME_MSG_MATCH_REQUEST = 1308, - GAME_MSG_MATCH_RESPONSE = 1309, - GAME_MSG_MATCH_UPDATE = 1310, - GAME_MSG_MODULE_ASSEMBLY_DB_DATA_FOR_CLIENT = 1131, - GAME_MSG_MODULE_ASSEMBLY_QUERY_DATA = 1132, - GAME_MSG_SHOW_BILLBOARD_INTERACT_ICON = 1337, - GAME_MSG_CHANGE_IDLE_FLAGS = 1338, - GAME_MSG_VEHICLE_ADD_PASSIVE_BOOST_ACTION = 1340, - GAME_MSG_VEHICLE_REMOVE_PASSIVE_BOOST_ACTION = 1341, - GAME_MSG_VEHICLE_NOTIFY_SERVER_ADD_PASSIVE_BOOST_ACTION = 1342, - GAME_MSG_VEHICLE_NOTIFY_SERVER_REMOVE_PASSIVE_BOOST_ACTION = 1343, - GAME_MSG_VEHICLE_ADD_SLOWDOWN_ACTION = 1344, - GAME_MSG_VEHICLE_REMOVE_SLOWDOWN_ACTION = 1345, - GAME_MSG_VEHICLE_NOTIFY_SERVER_ADD_SLOWDOWN_ACTION = 1346, - GAME_MSG_VEHICLE_NOTIFY_SERVER_REMOVE_SLOWDOWN_ACTION = 1347, - GAME_MSG_BUYBACK_FROM_VENDOR = 1350, - GAME_MSG_SET_PROPERTY_ACCESS = 1366, - GAME_MSG_ZONE_PROPERTY_MODEL_PLACED = 1369, - GAME_MSG_ZONE_PROPERTY_MODEL_ROTATED = 1370, - GAME_MSG_ZONE_PROPERTY_MODEL_REMOVED_WHILE_EQUIPPED = 1371, - GAME_MSG_ZONE_PROPERTY_MODEL_EQUIPPED = 1372, - GAME_MSG_ZONE_PROPERTY_MODEL_PICKED_UP = 1373, - GAME_MSG_ZONE_PROPERTY_MODEL_REMOVED = 1374, - GAME_MSG_NOTIFY_RACING_CLIENT = 1390, - GAME_MSG_RACING_PLAYER_HACK_CAR = 1391, - GAME_MSG_RACING_PLAYER_LOADED = 1392, - GAME_MSG_RACING_CLIENT_READY = 1393, - GAME_MSG_UPDATE_CHAT_MODE = 1395, - GAME_MSG_VEHICLE_NOTIFY_FINISHED_RACE = 1396, - GAME_MSG_SET_CONSUMABLE_ITEM = 1409, - GAME_MSG_SET_STATUS_IMMUNITY = 1435, - GAME_MSG_SET_PET_NAME_MODERATED = 1448, - GAME_MSG_MODIFY_LEGO_SCORE = 1459, - GAME_MSG_RESTORE_TO_POST_LOAD_STATS = 1468, - GAME_MSG_SET_RAIL_MOVEMENT = 1471, - GAME_MSG_START_RAIL_MOVEMENT = 1472, - GAME_MSG_CANCEL_RAIL_MOVEMENT = 1474, - GAME_MSG_CLIENT_RAIL_MOVEMENT_READY = 1476, - GAME_MSG_PLAYER_RAIL_ARRIVED_NOTIFICATION = 1477, - GAME_MSG_UPDATE_PLAYER_STATISTIC = 1481, - GAME_MSG_MODULAR_ASSEMBLY_NIF_COMPLETED = 1498, - GAME_MSG_NOTIFY_NOT_ENOUGH_INV_SPACE = 1516, - GAME_MSG_TEAM_SET_LEADER = 0x0615, - GAME_MSG_TEAM_INVITE_CONFIRM = 0x0616, - GAME_MSG_TEAM_GET_STATUS_RESPONSE = 0x0617, - GAME_MSG_TEAM_ADD_PLAYER = 0x061a, - GAME_MSG_TEAM_REMOVE_PLAYER = 0x061b, - GAME_MSG_START_CELEBRATION_EFFECT = 1618, - GAME_MSG_ADD_BUFF = 1647, - GAME_MSG_SERVER_DONE_LOADING_ALL_OBJECTS = 1642, - GAME_MSG_PLACE_PROPERTY_MODEL = 1170, - GAME_MSG_VEHICLE_NOTIFY_HIT_IMAGINATION_SERVER = 1606, - GAME_MSG_ADD_RUN_SPEED_MODIFIER = 1505, - GAME_MSG_HANDLE_HOT_PROPERTY_DATA = 1511, - GAME_MSG_SEND_HOT_PROPERTY_DATA = 1510, - GAME_MSG_REMOVE_RUN_SPEED_MODIFIER = 1506, - GAME_MSG_UPDATE_PROPERTY_PERFORMANCE_COST = 1547, - GAME_MSG_PROPERTY_ENTRANCE_BEGIN = 1553, - GAME_MSG_SET_RESURRECT_RESTORE_VALUES = 1591, - GAME_MSG_VEHICLE_STOP_BOOST = 1617, - GAME_MSG_REMOVE_BUFF = 1648, - GAME_MSG_REQUEST_MOVE_ITEM_BETWEEN_INVENTORY_TYPES = 1666, - GAME_MSG_RESPONSE_MOVE_ITEM_BETWEEN_INVENTORY_TYPES = 1667, - GAME_MSG_PLAYER_SET_CAMERA_CYCLING_MODE = 1676, - GAME_MSG_SET_MOUNT_INVENTORY_ID = 1726, - GAME_MSG_NOTIFY_SERVER_LEVEL_PROCESSING_COMPLETE = 1734, - GAME_MSG_NOTIFY_LEVEL_REWARDS = 1735, - GAME_MSG_DISMOUNT_COMPLETE = 1756, - GAME_MSG_MARK_INVENTORY_ITEM_AS_ACTIVE = 1767, - END -}; diff --git a/dCommon/dEnums/eAuthMessageType.h b/dCommon/dEnums/eAuthMessageType.h new file mode 100644 index 00000000..ecc17a37 --- /dev/null +++ b/dCommon/dEnums/eAuthMessageType.h @@ -0,0 +1,15 @@ +#ifndef __EAUTHMESSAGETYPE__H__ +#define __EAUTHMESSAGETYPE__H__ + +#include + +enum class eAuthMessageType : uint32_t { + LOGIN_REQUEST = 0, + LOGOUT_REQUEST, + CREATE_NEW_ACCOUNT_REQUEST, + LEGOINTERFACE_AUTH_RESPONSE, + SESSIONKEY_RECEIVED_CONFIRM, + RUNTIME_CONFIG +}; + +#endif //!__EAUTHMESSAGETYPE__H__ diff --git a/dCommon/dEnums/eBuildType.h b/dCommon/dEnums/eBuildType.h new file mode 100644 index 00000000..f28f43cc --- /dev/null +++ b/dCommon/dEnums/eBuildType.h @@ -0,0 +1,12 @@ +#ifndef __EBUILDTYPE__H__ +#define __EBUILDTYPE__H__ + +#include + +enum class eBuildType :uint32_t { + NOWHERE, + IN_WORLD, + ON_PROPERTY +}; + +#endif //!__EBUILDTYPE__H__ diff --git a/dCommon/dEnums/eCharacterCreationResponse.h b/dCommon/dEnums/eCharacterCreationResponse.h new file mode 100644 index 00000000..da1ec0f2 --- /dev/null +++ b/dCommon/dEnums/eCharacterCreationResponse.h @@ -0,0 +1,14 @@ +#ifndef __ECHARACTERCREATIONRESPONSE__H__ +#define __ECHARACTERCREATIONRESPONSE__H__ + +#include + +enum class eCharacterCreationResponse : uint8_t { + SUCCESS = 0, + OBJECT_ID_UNAVAILABLE, + NAME_NOT_ALLOWED, + PREDEFINED_NAME_IN_USE, + CUSTOM_NAME_IN_USE +}; + +#endif //!__ECHARACTERCREATIONRESPONSE__H__ diff --git a/dCommon/dEnums/eChatInternalMessageType.h b/dCommon/dEnums/eChatInternalMessageType.h new file mode 100644 index 00000000..d3b7020b --- /dev/null +++ b/dCommon/dEnums/eChatInternalMessageType.h @@ -0,0 +1,31 @@ +#ifndef __ECHATINTERNALMESSAGETYPE__H__ +#define __ECHATINTERNALMESSAGETYPE__H__ + +#include + +enum eChatInternalMessageType : uint32_t { + PLAYER_ADDED_NOTIFICATION = 0, + PLAYER_REMOVED_NOTIFICATION, + ADD_FRIEND, + ADD_BEST_FRIEND, + ADD_TO_TEAM, + ADD_BLOCK, + REMOVE_FRIEND, + REMOVE_BLOCK, + REMOVE_FROM_TEAM, + DELETE_TEAM, + REPORT, + PRIVATE_CHAT, + PRIVATE_CHAT_RESPONSE, + ANNOUNCEMENT, + MAIL_COUNT_UPDATE, + MAIL_SEND_NOTIFY, + REQUEST_USER_LIST, + FRIEND_LIST, + ROUTE_TO_PLAYER, + TEAM_UPDATE, + MUTE_UPDATE, + CREATE_TEAM, +}; + +#endif //!__ECHATINTERNALMESSAGETYPE__H__ diff --git a/dCommon/dEnums/eChatMessageType.h b/dCommon/dEnums/eChatMessageType.h new file mode 100644 index 00000000..52895ba3 --- /dev/null +++ b/dCommon/dEnums/eChatMessageType.h @@ -0,0 +1,78 @@ +#ifndef __ECHATMESSAGETYPE__H__ +#define __ECHATMESSAGETYPE__H__ + +#include + +//! The Internal Chat Packet Identifiers +enum class eChatMessageType :uint32_t { + LOGIN_SESSION_NOTIFY = 0, + GENERAL_CHAT_MESSAGE, + PRIVATE_CHAT_MESSAGE, + USER_CHANNEL_CHAT_MESSAGE, + WORLD_DISCONNECT_REQUEST, + WORLD_PROXIMITY_RESPONSE, + WORLD_PARCEL_RESPONSE, + ADD_FRIEND_REQUEST, + ADD_FRIEND_RESPONSE, + REMOVE_FRIEND, + GET_FRIENDS_LIST, + ADD_IGNORE, + REMOVE_IGNORE, + GET_IGNORE_LIST, + TEAM_MISSED_INVITE_CHECK, + TEAM_INVITE, + TEAM_INVITE_RESPONSE, + TEAM_KICK, + TEAM_LEAVE, + TEAM_SET_LOOT, + TEAM_SET_LEADER, + TEAM_GET_STATUS, + GUILD_CREATE, + GUILD_INVITE, + GUILD_INVITE_RESPONSE, + GUILD_LEAVE, + GUILD_KICK, + GUILD_GET_STATUS, + GUILD_GET_ALL, + SHOW_ALL, + BLUEPRINT_MODERATED, + BLUEPRINT_MODEL_READY, + PROPERTY_READY_FOR_APPROVAL, + PROPERTY_MODERATION_CHANGED, + PROPERTY_BUILDMODE_CHANGED, + PROPERTY_BUILDMODE_CHANGED_REPORT, + MAIL, + WORLD_INSTANCE_LOCATION_REQUEST, + REPUTATION_UPDATE, + SEND_CANNED_TEXT, + GMLEVEL_UPDATE, + CHARACTER_NAME_CHANGE_REQUEST, + CSR_REQUEST, + CSR_REPLY, + GM_KICK, + GM_ANNOUNCE, + GM_MUTE, + ACTIVITY_UPDATE, + WORLD_ROUTE_PACKET, + GET_ZONE_POPULATIONS, + REQUEST_MINIMUM_CHAT_MODE, + REQUEST_MINIMUM_CHAT_MODE_PRIVATE, + MATCH_REQUEST, + UGCMANIFEST_REPORT_MISSING_FILE, + UGCMANIFEST_REPORT_DONE_FILE, + UGCMANIFEST_REPORT_DONE_BLUEPRINT, + UGCC_REQUEST, + WHO, + WORLD_PLAYERS_PET_MODERATED_ACKNOWLEDGE, + ACHIEVEMENT_NOTIFY, + GM_CLOSE_PRIVATE_CHAT_WINDOW, + UNEXPECTED_DISCONNECT, + PLAYER_READY, + GET_DONATION_TOTAL, + UPDATE_DONATION, + PRG_CSR_COMMAND, + HEARTBEAT_REQUEST_FROM_WORLD, + UPDATE_FREE_TRIAL_STATUS +}; + +#endif //!__ECHATMESSAGETYPE__H__ diff --git a/dCommon/dEnums/eCinematicEvent.h b/dCommon/dEnums/eCinematicEvent.h new file mode 100644 index 00000000..7fb82ca7 --- /dev/null +++ b/dCommon/dEnums/eCinematicEvent.h @@ -0,0 +1,12 @@ +#ifndef __ECINEMATICEVENT__H__ +#define __ECINEMATICEVENT__H__ + +#include + +enum class eCinematicEvent : uint32_t { + STARTED, + WAYPOINT, + ENDED, +}; + +#endif //!__ECINEMATICEVENT__H__ diff --git a/dCommon/dEnums/eClientMessageType.h b/dCommon/dEnums/eClientMessageType.h new file mode 100644 index 00000000..aafccc36 --- /dev/null +++ b/dCommon/dEnums/eClientMessageType.h @@ -0,0 +1,76 @@ +#ifndef __ECLIENTMESSAGETYPE__H__ +#define __ECLIENTMESSAGETYPE__H__ + +#include + +enum class eClientMessageType : uint32_t { + LOGIN_RESPONSE = 0, + LOGOUT_RESPONSE, + LOAD_STATIC_ZONE, + CREATE_OBJECT, + CREATE_CHARACTER, + CREATE_CHARACTER_EXTENDED, + CHARACTER_LIST_RESPONSE, + CHARACTER_CREATE_RESPONSE, + CHARACTER_RENAME_RESPONSE, + CHAT_CONNECT_RESPONSE, + AUTH_ACCOUNT_CREATE_RESPONSE, + DELETE_CHARACTER_RESPONSE, + GAME_MSG, + CONNECT_CHAT, + TRANSFER_TO_WORLD, + IMPENDING_RELOAD_NOTIFY, + MAKE_GM_RESPONSE, + HTTP_MONITOR_INFO_RESPONSE, + SLASH_PUSH_MAP_RESPONSE, + SLASH_PULL_MAP_RESPONSE, + SLASH_LOCK_MAP_RESPONSE, + BLUEPRINT_SAVE_RESPONSE, + BLUEPRINT_LUP_SAVE_RESPONSE, + BLUEPRINT_LOAD_RESPONSE_ITEMID, + BLUEPRINT_GET_ALL_DATA_RESPONSE, + MODEL_INSTANTIATE_RESPONSE, + DEBUG_OUTPUT, + ADD_FRIEND_REQUEST, + ADD_FRIEND_RESPONSE, + REMOVE_FRIEND_RESPONSE, + GET_FRIENDS_LIST_RESPONSE, + UPDATE_FRIEND_NOTIFY, + ADD_IGNORE_RESPONSE, + REMOVE_IGNORE_RESPONSE, + GET_IGNORE_LIST_RESPONSE, + TEAM_INVITE, + TEAM_INVITE_INITIAL_RESPONSE, + GUILD_CREATE_RESPONSE, + GUILD_GET_STATUS_RESPONSE, + GUILD_INVITE, + GUILD_INVITE_INITIAL_RESPONSE, + GUILD_INVITE_FINAL_RESPONSE, + GUILD_INVITE_CONFIRM, + GUILD_ADD_PLAYER, + GUILD_REMOVE_PLAYER, + GUILD_LOGIN_LOGOUT, + GUILD_RANK_CHANGE, + GUILD_DATA, + GUILD_STATUS, + MAIL, + DB_PROXY_RESULT, + SHOW_ALL_RESPONSE, + WHO_RESPONSE, + SEND_CANNED_TEXT, + UPDATE_CHARACTER_NAME, + SET_NETWORK_SIMULATOR, + INVALID_CHAT_MESSAGE, + MINIMUM_CHAT_MODE_RESPONSE, + MINIMUM_CHAT_MODE_RESPONSE_PRIVATE, + CHAT_MODERATION_STRING, + UGC_MANIFEST_RESPONSE, + IN_LOGIN_QUEUE, + SERVER_STATES, + GM_CLOSE_TARGET_CHAT_WINDOW, + GENERAL_TEXT_FOR_LOCALIZATION, + UPDATE_FREE_TRIAL_STATUS, + UGC_DOWNLOAD_FAILED = 120 +}; + +#endif //!__ECLIENTMESSAGETYPE__H__ diff --git a/dCommon/dEnums/eConnectionType.h b/dCommon/dEnums/eConnectionType.h new file mode 100644 index 00000000..ce1ff90c --- /dev/null +++ b/dCommon/dEnums/eConnectionType.h @@ -0,0 +1,14 @@ +#ifndef __ECONNECTIONTYPE__H__ +#define __ECONNECTIONTYPE__H__ + +enum class eConnectionType : uint16_t { + SERVER = 0, + AUTH, + CHAT, + CHAT_INTERNAL, + WORLD, + CLIENT, + MASTER +}; + +#endif //!__ECONNECTIONTYPE__H__ diff --git a/dCommon/dEnums/eControlScheme.h b/dCommon/dEnums/eControlScheme.h new file mode 100644 index 00000000..f7585ebb --- /dev/null +++ b/dCommon/dEnums/eControlScheme.h @@ -0,0 +1,18 @@ +#ifndef __ECONTROLSCHEME__H__ +#define __ECONTROLSCHEME__H__ + +#include + +enum class eControlScheme : uint32_t { + SCHEME_A, + SCHEME_D, + SCHEME_GAMEPAD, + SCHEME_E, + SCHEME_FPS, + SCHEME_DRIVING, + SCHEME_TAMING, + SCHEME_MODULAR_BUILD, + SCHEME_WEAR_A_ROBOT //== freecam? +}; + +#endif //!__ECONTROLSCHEME__H__ diff --git a/dCommon/dEnums/eCyclingMode.h b/dCommon/dEnums/eCyclingMode.h new file mode 100644 index 00000000..b5e3248b --- /dev/null +++ b/dCommon/dEnums/eCyclingMode.h @@ -0,0 +1,11 @@ +#ifndef __ECYCLINGMODE__H__ +#define __ECYCLINGMODE__H__ + +#include + +enum class eCyclingMode : uint32_t { + ALLOW_CYCLE_TEAMMATES, + DISALLOW_CYCLING +}; + +#endif //!__ECYCLINGMODE__H__ diff --git a/dCommon/dEnums/eGameActivity.h b/dCommon/dEnums/eGameActivity.h new file mode 100644 index 00000000..16b75380 --- /dev/null +++ b/dCommon/dEnums/eGameActivity.h @@ -0,0 +1,15 @@ +#ifndef __EGAMEACTIVITY__H__ +#define __EGAMEACTIVITY__H__ + +#include + +enum class eGameActivity : uint32_t { + NONE, + QUICKBUILDING, + SHOOTING_GALLERY, + RACING, + PINBALL, + PET_TAMING +}; + +#endif //!__EGAMEACTIVITY__H__ diff --git a/dCommon/dEnums/eGameMessageType.h b/dCommon/dEnums/eGameMessageType.h new file mode 100644 index 00000000..051a5ae8 --- /dev/null +++ b/dCommon/dEnums/eGameMessageType.h @@ -0,0 +1,303 @@ +#ifndef __EGAMEMESSAGETYPE__H__ +#define __EGAMEMESSAGETYPE__H__ + +#include + +enum class eGameMessageType : uint16_t { + TELEPORT = 19, + SET_PLAYER_CONTROL_SCHEME = 26, + DROP_CLIENT_LOOT = 30, + DIE = 37, + REQUEST_DIE = 38, + PLAY_EMOTE = 41, + PLAY_ANIMATION = 43, + CONTROL_BEHAVIOR = 48, + SET_NAME = 72, + ECHO_START_SKILL = 118, + START_SKILL = 119, + VERIFY_ACK = 121, + ADD_SKILL = 127, + REMOVE_SKILL = 128, + SET_CURRENCY = 133, + PICKUP_CURRENCY = 137, + PICKUP_ITEM = 139, + TEAM_PICKUP_ITEM = 140, + PLAY_FX_EFFECT = 154, + STOP_FX_EFFECT = 155, + REQUEST_RESURRECT = 159, + RESURRECT = 160, + PUSH_EQUIPPED_ITEMS_STATE = 191, + POP_EQUIPPED_ITEMS_STATE = 192, + SET_GM_LEVEL = 193, + SET_STUNNED = 198, + SET_STUN_IMMUNITY = 200, + KNOCKBACK = 202, + REBUILD_CANCEL = 209, + ENABLE_REBUILD = 213, + MOVE_ITEM_IN_INVENTORY = 224, + ADD_ITEM_TO_INVENTORY_CLIENT_SYNC = 227, + REMOVE_ITEM_FROM_INVENTORY = 230, + EQUIP_ITEM = 231, + UN_EQUIP_ITEM = 233, + OFFER_MISSION = 248, + RESPOND_TO_MISSION = 249, + NOTIFY_MISSION = 254, + NOTIFY_MISSION_TASK = 255, + REBUILD_NOTIFY_STATE = 336, + TERMINATE_INTERACTION = 357, + SERVER_TERMINATE_INTERACTION = 358, + REQUEST_USE = 364, + VENDOR_OPEN_WINDOW = 369, + BUY_FROM_VENDOR = 373, + SELL_TO_VENDOR = 374, + TEAM_SET_OFF_WORLD_FLAG = 383, + SET_INVENTORY_SIZE = 389, + ACKNOWLEDGE_POSSESSION = 391, + SET_SHOOTING_GALLERY_PARAMS = 400, + REQUEST_ACTIVITY_START_STOP = 402, + REQUEST_ACTIVITY_ENTER = 403, + REQUEST_ACTIVITY_EXIT = 404, + ACTIVITY_ENTER = 405, + ACTIVITY_EXIT = 406, + ACTIVITY_START = 407, + ACTIVITY_STOP = 408, + SHOOTING_GALLERY_CLIENT_AIM_UPDATE = 409, + SHOOTING_GALLERY_FIRE = 411, + REQUEST_VENDOR_STATUS_UPDATE = 416, + VENDOR_STATUS_UPDATE = 417, + NOTIFY_CLIENT_SHOOTING_GALLERY_SCORE = 425, + CONSUME_CLIENT_ITEM = 427, + CLIENT_ITEM_CONSUMED = 428, + UPDATE_SHOOTING_GALLERY_ROTATION = 448, + SET_FLAG = 471, + NOTIFY_CLIENT_FLAG_CHANGE = 472, + VENDOR_TRANSACTION_RESULT = 476, + HAS_BEEN_COLLECTED = 486, + DISPLAY_CHAT_BUBBLE = 495, + SPAWN_PET = 498, + DESPAWN_PET = 499, + PLAYER_LOADED = 505, + PLAYER_READY = 509, + REQUEST_LINKED_MISSION = 515, + INVALID_ZONE_TRANSFER_LIST = 519, + MISSION_DIALOGUE_OK = 520, + DISPLAY_MESSAGE_BOX = 529, + MESSAGE_BOX_RESPOND = 530, + CHOICE_BOX_RESPOND = 531, + SMASH = 537, + UNSMASH = 538, + PLACE_MODEL_RESPONSE = 547, + SET_SHOOTING_GALLERY_RETICULE_EFFECT = 548, + SET_JET_PACK_MODE = 561, + REGISTER_PET_ID = 565, + REGISTER_PET_DBID = 566, + SHOW_ACTIVITY_COUNTDOWN = 568, + START_ACTIVITY_TIME = 576, + ACTIVITY_PAUSE = 602, + USE_NON_EQUIPMENT_ITEM = 603, + USE_ITEM_RESULT = 607, + COMMAND_PET = 640, + PET_RESPONSE = 641, + REQUEST_ACTIVITY_SUMMARY_LEADERBOARD_DATA = 648, + SEND_ACTIVITY_SUMMARY_LEADERBOARD_DATA = 649, + NOTIFY_OBJECT = 656, + CLIENT_NOTIFY_PET = 659, + NOTIFY_PET = 660, + NOTIFY_PET_TAMING_MINIGAME = 661, + START_SERVER_PET_MINIGAME_TIMER = 662, + CLIENT_EXIT_TAMING_MINIGAME = 663, + PET_NAME_CHANGED = 686, + PET_TAMING_MINIGAME_RESULT = 667, + PET_TAMING_TRY_BUILD_RESULT = 668, + NOTIFY_TAMING_BUILD_SUCCESS = 673, + NOTIFY_TAMING_MODEL_LOADED_ON_SERVER = 674, + ACTIVATE_BUBBLE_BUFF = 678, + DEACTIVATE_BUBBLE_BUFF = 679, + ADD_PET_TO_PLAYER = 681, + REQUEST_SET_PET_NAME = 683, + SET_PET_NAME = 684, + NOTIFY_PET_TAMING_PUZZLE_SELECTED = 675, + SHOW_PET_ACTION_BUTTON = 692, + SET_EMOTE_LOCK_STATE = 693, + USE_ITEM_REQUIREMENTS_RESPONSE = 703, + PLAY_EMBEDDED_EFFECT_ON_ALL_CLIENTS_NEAR_OBJECT = 713, + DOWNLOAD_PROPERTY_DATA = 716, + QUERY_PROPERTY_DATA = 717, + PROPERTY_EDITOR_BEGIN = 724, + PROPERTY_EDITOR_END = 725, + IS_MINIFIG_IN_A_BUBBLE = 729, + START_PATHING = 733, + ACTIVATE_BUBBLE_BUFF_FROM_SERVER = 734, + DEACTIVATE_BUBBLE_BUFF_FROM_SERVER = 735, + NOTIFY_CLIENT_ZONE_OBJECT = 737, + UPDATE_REPUTATION = 746, + PROPERTY_RENTAL_RESPONSE = 750, + REQUEST_PLATFORM_RESYNC = 760, + PLATFORM_RESYNC = 761, + PLAY_CINEMATIC = 762, + END_CINEMATIC = 763, + CINEMATIC_UPDATE = 764, + TOGGLE_GHOST_REFERENCE_OVERRIDE = 767, + SET_GHOST_REFERENCE_POSITION = 768, + FIRE_EVENT_SERVER_SIDE = 770, + SET_NETWORK_SCRIPT_VAR = 781, + UPDATE_MODEL_FROM_CLIENT = 793, + DELETE_MODEL_FROM_CLIENT = 794, + PLAY_ND_AUDIO_EMITTER = 821, + PLAY2_DAMBIENT_SOUND = 831, + ENTER_PROPERTY1 = 840, + ENTER_PROPERTY2 = 841, + PROPERTY_ENTRANCE_SYNC = 842, + PROPERTY_SELECT_QUERY = 845, + PARSE_CHAT_MESSAGE = 850, + BROADCAST_TEXT_TO_CHATBOX = 858, + OPEN_PROPERTY_MANAGEMENT = 860, + OPEN_PROPERTY_VENDOR = 861, + UPDATE_PROPERTY_OR_MODEL_FOR_FILTER_CHECK = 863, + CLIENT_TRADE_REQUEST = 868, + SERVER_TRADE_REQUEST = 869, + SERVER_TRADE_INVITE = 870, + CLIENT_TRADE_REPLY = 871, + SERVER_TRADE_REPLY = 872, + SERVER_TRADE_INITIAL_REPLY = 873, + SERVER_TRADE_FINAL_REPLY = 874, + CLIENT_TRADE_UPDATE = 875, + SERVER_SIDE_TRADE_UPDATE = 876, + SERVER_TRADE_UPDATE = 877, + CLIENT_TRADE_CANCEL = 878, + CLIENT_SIDE_TRADE_CANCEL = 879, + CLIENT_TRADE_ACCEPT = 880, + SERVER_SIDE_TRADE_ACCEPT = 881, + SERVER_SIDE_TRADE_CANCEL = 882, + SERVER_TRADE_CANCEL = 883, + SERVER_TRADE_ACCEPT = 884, + READY_FOR_UPDATES = 888, + ORIENT_TO_OBJECT = 905, + ORIENT_TO_POSITION = 906, + ORIENT_TO_ANGLE = 907, + BOUNCER_ACTIVE_STATUS = 942, + UN_USE_BBB_MODEL = 999, + BBB_LOAD_ITEM_REQUEST = 1000, + BBB_SAVE_REQUEST = 1001, + BBB_SAVE_RESPONSE = 1006, + NOTIFY_CLIENT_OBJECT = 1042, + DISPLAY_ZONE_SUMMARY = 1043, + ZONE_SUMMARY_DISMISSED = 1044, + ACTIVITY_STATE_CHANGE_REQUEST = 1053, + MODIFY_PLAYER_ZONE_STATISTIC = 1046, + START_BUILDING_WITH_ITEM = 1057, + START_ARRANGING_WITH_ITEM = 1061, + FINISH_ARRANGING_WITH_ITEM = 1062, + DONE_ARRANGING_WITH_ITEM = 1063, + SET_BUILD_MODE = 1068, + BUILD_MODE_SET = 1069, + SET_BUILD_MODE_CONFIRMED = 1073, + NOTIFY_CLIENT_FAILED_PRECONDITION = 1081, + MOVE_ITEM_BETWEEN_INVENTORY_TYPES = 1093, + MODULAR_BUILD_BEGIN = 1094, + MODULAR_BUILD_END = 1095, + MODULAR_BUILD_MOVE_AND_EQUIP = 1096, + MODULAR_BUILD_FINISH = 1097, + REPORT_BUG = 1198, + MISSION_DIALOGUE_CANCELLED = 1129, + ECHO_SYNC_SKILL = 1144, + SYNC_SKILL = 1145, + REQUEST_SERVER_PROJECTILE_IMPACT = 1148, + DO_CLIENT_PROJECTILE_IMPACT = 1151, + MODULAR_BUILD_CONVERT_MODEL = 1155, + SET_PLAYER_ALLOWED_RESPAWN = 1165, + UI_MESSAGE_SERVER_TO_SINGLE_CLIENT = 1184, + UI_MESSAGE_SERVER_TO_ALL_CLIENTS = 1185, + PET_TAMING_TRY_BUILD = 1197, + REQUEST_SMASH_PLAYER = 1202, + FIRE_EVENT_CLIENT_SIDE = 1213, + TOGGLE_GM_INVIS = 1218, + CHANGE_OBJECT_WORLD_STATE = 1223, + VEHICLE_LOCK_INPUT = 1230, + VEHICLE_UNLOCK_INPUT = 1231, + RACING_RESET_PLAYER_TO_LAST_RESET = 1252, + RACING_SERVER_SET_PLAYER_LAP_AND_PLANE = 1253, + RACING_SET_PLAYER_RESET_INFO = 1254, + RACING_PLAYER_INFO_RESET_FINISHED = 1255, + LOCK_NODE_ROTATION = 1260, + VEHICLE_SET_WHEEL_LOCK_STATE = 1273, + NOTIFY_VEHICLE_OF_RACING_OBJECT = 1276, + SET_NAME_BILLBOARD_STATE = 1284, + PLAYER_REACHED_RESPAWN_CHECKPOINT = 1296, + HANDLE_UGC_EQUIP_POST_DELETE_BASED_ON_EDIT_MODE = 1300, + HANDLE_UGC_EQUIP_PRE_CREATE_BASED_ON_EDIT_MODE = 1301, + PROPERTY_CONTENTS_FROM_CLIENT = 1305, + GET_MODELS_ON_PROPERTY = 1306, + MATCH_REQUEST = 1308, + MATCH_RESPONSE = 1309, + MATCH_UPDATE = 1310, + MODULE_ASSEMBLY_DB_DATA_FOR_CLIENT = 1131, + MODULE_ASSEMBLY_QUERY_DATA = 1132, + SHOW_BILLBOARD_INTERACT_ICON = 1337, + CHANGE_IDLE_FLAGS = 1338, + VEHICLE_ADD_PASSIVE_BOOST_ACTION = 1340, + VEHICLE_REMOVE_PASSIVE_BOOST_ACTION = 1341, + VEHICLE_NOTIFY_SERVER_ADD_PASSIVE_BOOST_ACTION = 1342, + VEHICLE_NOTIFY_SERVER_REMOVE_PASSIVE_BOOST_ACTION = 1343, + VEHICLE_ADD_SLOWDOWN_ACTION = 1344, + VEHICLE_REMOVE_SLOWDOWN_ACTION = 1345, + VEHICLE_NOTIFY_SERVER_ADD_SLOWDOWN_ACTION = 1346, + VEHICLE_NOTIFY_SERVER_REMOVE_SLOWDOWN_ACTION = 1347, + BUYBACK_FROM_VENDOR = 1350, + SET_PROPERTY_ACCESS = 1366, + ZONE_PROPERTY_MODEL_PLACED = 1369, + ZONE_PROPERTY_MODEL_ROTATED = 1370, + ZONE_PROPERTY_MODEL_REMOVED_WHILE_EQUIPPED = 1371, + ZONE_PROPERTY_MODEL_EQUIPPED = 1372, + ZONE_PROPERTY_MODEL_PICKED_UP = 1373, + ZONE_PROPERTY_MODEL_REMOVED = 1374, + NOTIFY_RACING_CLIENT = 1390, + RACING_PLAYER_HACK_CAR = 1391, + RACING_PLAYER_LOADED = 1392, + RACING_CLIENT_READY = 1393, + UPDATE_CHAT_MODE = 1395, + VEHICLE_NOTIFY_FINISHED_RACE = 1396, + SET_CONSUMABLE_ITEM = 1409, + SET_STATUS_IMMUNITY = 1435, + SET_PET_NAME_MODERATED = 1448, + MODIFY_LEGO_SCORE = 1459, + RESTORE_TO_POST_LOAD_STATS = 1468, + SET_RAIL_MOVEMENT = 1471, + START_RAIL_MOVEMENT = 1472, + CANCEL_RAIL_MOVEMENT = 1474, + CLIENT_RAIL_MOVEMENT_READY = 1476, + PLAYER_RAIL_ARRIVED_NOTIFICATION = 1477, + UPDATE_PLAYER_STATISTIC = 1481, + MODULAR_ASSEMBLY_NIF_COMPLETED = 1498, + NOTIFY_NOT_ENOUGH_INV_SPACE = 1516, + TEAM_SET_LEADER = 1557, + TEAM_INVITE_CONFIRM = 1558, + TEAM_GET_STATUS_RESPONSE = 1559, + TEAM_ADD_PLAYER = 1562, + TEAM_REMOVE_PLAYER = 1563, + START_CELEBRATION_EFFECT = 1618, + ADD_BUFF = 1647, + SERVER_DONE_LOADING_ALL_OBJECTS = 1642, + PLACE_PROPERTY_MODEL = 1170, + VEHICLE_NOTIFY_HIT_IMAGINATION_SERVER = 1606, + ADD_RUN_SPEED_MODIFIER = 1505, + HANDLE_HOT_PROPERTY_DATA = 1511, + SEND_HOT_PROPERTY_DATA = 1510, + REMOVE_RUN_SPEED_MODIFIER = 1506, + UPDATE_PROPERTY_PERFORMANCE_COST = 1547, + PROPERTY_ENTRANCE_BEGIN = 1553, + SET_RESURRECT_RESTORE_VALUES = 1591, + VEHICLE_STOP_BOOST = 1617, + REMOVE_BUFF = 1648, + REQUEST_MOVE_ITEM_BETWEEN_INVENTORY_TYPES = 1666, + RESPONSE_MOVE_ITEM_BETWEEN_INVENTORY_TYPES = 1667, + PLAYER_SET_CAMERA_CYCLING_MODE = 1676, + SET_MOUNT_INVENTORY_ID = 1726, + NOTIFY_SERVER_LEVEL_PROCESSING_COMPLETE = 1734, + NOTIFY_LEVEL_REWARDS = 1735, + DISMOUNT_COMPLETE = 1756, + MARK_INVENTORY_ITEM_AS_ACTIVE = 1767, + END +}; + +#endif //!__EGAMEMESSAGETYPE__H__ diff --git a/dCommon/dEnums/eKillType.h b/dCommon/dEnums/eKillType.h new file mode 100644 index 00000000..fe3908c8 --- /dev/null +++ b/dCommon/dEnums/eKillType.h @@ -0,0 +1,11 @@ +#ifndef __EKILLTYPE__H__ +#define __EKILLTYPE__H__ + +#include + +enum class eKillType : uint32_t { + VIOLENT, + SILENT +}; + +#endif //!__EKILLTYPE__H__ diff --git a/dCommon/dEnums/eLoginResponse.h b/dCommon/dEnums/eLoginResponse.h new file mode 100644 index 00000000..01bba3d5 --- /dev/null +++ b/dCommon/dEnums/eLoginResponse.h @@ -0,0 +1,24 @@ +#ifndef __ELOGINRESPONSE__H__ +#define __ELOGINRESPONSE__H__ + +#include + +enum class eLoginResponse : uint8_t { + GENERAL_FAILED = 0, + SUCCESS, + BANNED, + // Unused 3 + // Unused 4 + PERMISSIONS_NOT_HIGH_ENOUGH = 5, + INVALID_USER, + ACCOUNT_LOCKED, + WRONG_PASS, + ACCOUNT_ACTIVATION_PENDING, + ACCOUNT_DISABLED, + GAME_TIME_EXPIRED, + FREE_TRIAL_ENDED, + PLAY_SCHEDULE_TIME_UP, + ACCOUNT_NOT_ACTIVATED +}; + +#endif //!__ELOGINRESPONSE__H__ diff --git a/dCommon/dEnums/eLootSourceType.h b/dCommon/dEnums/eLootSourceType.h new file mode 100644 index 00000000..b8ecca4a --- /dev/null +++ b/dCommon/dEnums/eLootSourceType.h @@ -0,0 +1,31 @@ +#ifndef __ELOOTSOURCETYPE__H__ +#define __ELOOTSOURCETYPE__H__ + +#include + +enum class eLootSourceType : uint32_t { + NONE = 0, + CHEST, + MISSION, + MAIL, + CURRENCY, + ACHIEVEMENT, + TRADE, + QUICKBUILD, + DELETION, + VENDOR, + ACTIVITY, + PICKUP, + BRICK, + PROPERTY, + MODERATION, + EXHIBIT, + INVENTORY, + CLAIMCODE, + CONSUMPTION, + CRAFTING, + LEVEL_REWARD, + RELOCATE +}; + +#endif //!__ELOOTSOURCETYPE__H__ diff --git a/dCommon/dEnums/eMasterMessageType.h b/dCommon/dEnums/eMasterMessageType.h new file mode 100644 index 00000000..5c867d70 --- /dev/null +++ b/dCommon/dEnums/eMasterMessageType.h @@ -0,0 +1,36 @@ +#ifndef __EMASTERMESSAGETYPE__H__ +#define __EMASTERMESSAGETYPE__H__ + +#include + +enum class eMasterMessageType : uint32_t { + REQUEST_PERSISTENT_ID = 1, + REQUEST_PERSISTENT_ID_RESPONSE, + REQUEST_ZONE_TRANSFER, + REQUEST_ZONE_TRANSFER_RESPONSE, + SERVER_INFO, + REQUEST_SESSION_KEY, + SET_SESSION_KEY, + SESSION_KEY_RESPONSE, + PLAYER_ADDED, + PLAYER_REMOVED, + + CREATE_PRIVATE_ZONE, + REQUEST_PRIVATE_ZONE, + + WORLD_READY, + PREP_ZONE, + + SHUTDOWN, + SHUTDOWN_RESPONSE, + SHUTDOWN_IMMEDIATE, + + SHUTDOWN_UNIVERSE, + + AFFIRM_TRANSFER_REQUEST, + AFFIRM_TRANSFER_RESPONSE, + + NEW_SESSION_ALERT +}; + +#endif //!__EMASTERMESSAGETYPE__H__ diff --git a/dCommon/dEnums/eMatchUpdate.h b/dCommon/dEnums/eMatchUpdate.h new file mode 100644 index 00000000..a42eecd3 --- /dev/null +++ b/dCommon/dEnums/eMatchUpdate.h @@ -0,0 +1,17 @@ +#ifndef __EMATCHUPDATE__H__ +#define __EMATCHUPDATE__H__ + +#include + +enum class eMatchUpdate : int32_t { + PLAYER_ADDED = 0, + PLAYER_REMOVED, + PHASE_CREATED, + PHASE_WAIT_READY, + PHASE_WAIT_START, + PLAYER_READY, + PLAYER_NOT_READY, + PLAYER_UPDATE +}; + +#endif //!__EMATCHUPDATE__H__ diff --git a/dCommon/dEnums/eObjectBits.h b/dCommon/dEnums/eObjectBits.h new file mode 100644 index 00000000..b978aad6 --- /dev/null +++ b/dCommon/dEnums/eObjectBits.h @@ -0,0 +1,13 @@ +#ifndef __EOBJECTBITS__H__ +#define __EOBJECTBITS__H__ + +#include + +enum class eObjectBits : size_t { + PERSISTENT = 32, + CLIENT = 46, + SPAWNED = 58, + CHARACTER = 60 +}; + +#endif //!__EOBJECTBITS__H__ diff --git a/dCommon/dEnums/eObjectWorldState.h b/dCommon/dEnums/eObjectWorldState.h new file mode 100644 index 00000000..9735a072 --- /dev/null +++ b/dCommon/dEnums/eObjectWorldState.h @@ -0,0 +1,12 @@ +#ifndef __EOBJECTWORLDSTATE__H__ +#define __EOBJECTWORLDSTATE__H__ + +#include + +enum class eObjectWorldState : uint32_t { + INWORLD, + ATTACHED, + INVENTORY +}; + +#endif //!__EOBJECTWORLDSTATE__H__ diff --git a/dCommon/dEnums/ePetTamingNotifyType.h b/dCommon/dEnums/ePetTamingNotifyType.h new file mode 100644 index 00000000..564e932f --- /dev/null +++ b/dCommon/dEnums/ePetTamingNotifyType.h @@ -0,0 +1,15 @@ +#ifndef __EPETTAMINGNOTIFYTYPE__H__ +#define __EPETTAMINGNOTIFYTYPE__H__ + +#include + +enum class ePetTamingNotifyType : uint32_t { + SUCCESS, + QUIT, + FAILED, + BEGIN, + READY, + NAMINGPET +}; + +#endif //!__EPETTAMINGNOTIFYTYPE__H__ diff --git a/dCommon/dEnums/ePlayerFlag.h b/dCommon/dEnums/ePlayerFlag.h new file mode 100644 index 00000000..fefdfb67 --- /dev/null +++ b/dCommon/dEnums/ePlayerFlag.h @@ -0,0 +1,172 @@ +#ifndef __EPLAYERFLAG__H__ +#define __EPLAYERFLAG__H__ + +#include + +enum ePlayerFlag : int32_t { + BTARR_TESTING = 0, + PLAYER_HAS_ENTERED_PET_RANCH = 1, + MINIMAP_UNLOCKED = 2, + ACTIVITY_REBUILDING_FAIL_TIME = 3, + ACTIVITY_REBUILDING_FAIL_RANGE = 4, + ACTIVITY_SHOOTING_GALLERY_HELP = 5, + HELP_WALKING_CONTROLS = 6, + FIRST_SMASHABLE = 7, + FIRST_IMAGINATION_PICKUP = 8, + FIRST_DAMAGE = 9, + FIRST_ITEM = 10, + FIRST_BRICK = 11, + FIRST_CONSUMABLE = 12, + FIRST_EQUIPPABLE = 13, + CHAT_HELP = 14, + FIRST_PET_TAMING_MINIGAME = 15, + FIRST_PET_ON_SWITCH = 16, + FIRST_PET_JUMPED_ON_SWITCH = 17, + FIRST_PET_FOUND_TREASURE = 18, + FIRST_PET_DUG_TREASURE = 19, + FIRST_PET_OWNER_ON_PET_BOUNCER = 20, + FIRST_PET_DESPAWN_NO_IMAGINATION = 21, + FIRST_PET_SELECTED_ENOUGH_BRICKS = 22, + FIRST_EMOTE_UNLOCKED = 23, + GF_PIRATE_REP = 24, + AG_BOB_CINEMATIC_EVENT = 25, + HELP_JUMPING_CONTROLS = 26, + HELP_DOUBLE_JUMP_CONTROLS = 27, + HELP_CAMERA_CONTROLS = 28, + HELP_ROTATE_CONTROLS = 29, + HELP_SMASH = 30, + MONUMENT_INTRO_MUSIC_PLAYED = 31, + BEGINNING_ZONE_SUMMARY_DISPLAYED = 32, + AG_FINISH_LINE_BUILT = 33, + AG_BOSS_AREA_FOUND = 34, + AG_LANDED_IN_BATTLEFIELD = 35, + GF_PLAYER_HAS_BEEN_TO_THE_RAVINE = 36, + MODULAR_BUILD_STARTED = 37, + MODULAR_BUILD_FINISHED_CLICK_BUTTON = 38, + THINKING_HAT_RECEIVED_GO_TO_MODULAR_BUILD_AREA = 39, + BUILD_AREA_ENTERED_MOD_NOT_ACTIVATED_PUT_ON_HAT = 40, + HAT_ON_INSIDE_OF_MOD_BUILD_EQUIP_A_MODULE_FROM_LEG = 41, + MODULE_EQUIPPED_PLACE_ON_GLOWING_BLUE_SPOT = 42, + FIRST_MODULE_PLACED_CORRECTLY_NOW_DO_THE_REST = 43, + ROCKET_COMPLETE_NOW_LAUNCH_FROM_PAD = 44, + JOINED_A_FACTION = 45, + VENTURE_FACTION = 46, + ASSEMBLY_FACTION = 47, + PARADOX_FACTION = 48, + SENTINEL_FACTION = 49, + LUP_WORLD_ACCESS = 50, + AG_FIRST_FLAG_COLLECTED = 51, + TOOLTIP_TALK_TO_SKYLAND_TO_GET_HAT = 52, + MODULAR_BUILD_PLAYER_PLACES_FIRST_MODEL_IN_SCRATCH = 53, + MODULAR_BUILD_FIRST_ARROW_DISPLAY_FOR_MODULE = 54, + AG_BEACON_QB_SO_THE_PLAYER_CAN_ALWAYS_BUILD_THEM = 55, + GF_PET_DIG_FLAG_1 = 56, + GF_PET_DIG_FLAG_2 = 57, + GF_PET_DIG_FLAG_3 = 58, + SUPPRESS_SPACESHIP_CINEMATIC_FLYTHROUGH = 59, + GF_PLAYER_FALL_DEATH = 60, + GF_PLAYER_CAN_GET_FLAG_1 = 61, + GF_PLAYER_CAN_GET_FLAG_2 = 62, + GF_PLAYER_CAN_GET_FLAG_3 = 63, + ENTER_BBB_FROM_PROPERTY_EDIT_CONFIRMATION_DIALOG = 64, + AG_FIRST_COMBAT_COMPLETE = 65, + AG_COMPLETE_BOB_MISSION = 66, + FIRST_MANUAL_PET_HIBERNATE = 69, + CAGED_SPIDER = 74, + IS_NEWS_SCREEN_VISIBLE = 114, + NJ_GARMADON_CINEMATIC_SEEN = 125, + EQUPPED_TRIAL_FACTION_GEAR = 126, + ELEPHANT_PET_3050 = 801, + CAT_PET_3054 = 803, + TRICERATOPS_PET_3195 = 806, + TERRIER_PET_3254 = 807, + SKUNK_PET_3261 = 811, + BUNNY_PET_3672 = 813, + CROCODILE_PET_3994 = 814, + DOBERMAN_PET_5635 = 815, + BUFFALO_PET_5636 = 816, + ROBOT_DOG_PET_5637 = 818, + RED_DRAGON_PET_5639 = 819, + TORTOISE_PET_5640 = 820, + GREEN_DRAGON_PET_5641 = 821, + PANDA_PET_5643 = 822, + MANTIS_PET_5642 = 823, + WARTHOG_PET_6720 = 824, + LION_PET_3520 = 825, + GOAT_PET_7638 = 818, + CRAB_PET_7694 = 827, + REINDEER_PET_12294 = 829, + STEGOSAURUS_PET_12431 = 830, + SABER_CAT_PET_12432 = 831, + GRYPHON_PET_12433 = 832, + ALINE_PET_12334 = 833, + UNKNOWN_PET = 834, + EARTH_DRAGON_PET_16210 = 836, + SKELETON_DRAGON_PET_13067 = 838, + AG_SPACE_SHIP_BINOC_AT_LAUNCH = 1001, + AG_SPACE_SHIP_BINOC_AT_LAUNCH_PLATFORM = 1002, + AG_SPACE_SHIP_BINOC_ON_PLATFORM_TO_LEFT_OF_START = 1003, + AG_SPACE_SHIP_BINOC_ON_PLATFORM_TO_RIGHT_OF_START = 1004, + AG_SPACE_SHIP_BINOC_AT_BOB = 1005, + AG_BATTLE_BINOC_FOR_TRICERETOPS = 1101, + AG_BATTLE_BINOC_AT_PARADOX = 1102, + AG_BATTLE_BINOC_AT_MISSION_GIVER = 1103, + AG_BATTLE_BINOC_AT_BECK = 1104, + AG_MONUMENT_BINOC_INTRO = 1105, + AG_MONUMENT_BINOC_OUTRO = 1106, + AG_LAUNCH_BINOC_INTRO = 1107, + AG_LAUNCH_BINOC_BISON = 1108, + AG_LAUNCH_BINOC_SHARK = 1109, + NS_BINOC_CONCERT_TRANSITION = 1201, + NS_BINOC_RACE_PLACE_TRANSITION = 1202, + NS_BINOC_BRICK_ANNEX_TRANSITION = 1203, + NS_BINOC_GF_LAUNCH = 1204, + NS_BINOC_FV_LAUNCH = 1205, + NS_BINOC_BRICK_ANNEX_WATER = 1206, + NS_BINOC_AG_LAUNCH_AT_RACE_PLACE = 1207, + NS_BINOC_AG_LAUNCH_AT_BRICK_ANNEX = 1208, + NS_BINOC_AG_LAUNCH_AT_PLAZA = 1209, + NS_BINOC_TBA = 1210, + NS_FLAG_COLLECTABLE_1_BY_JONNY_THUNDER = 1211, + NS_FLAG_COLLECTABLE_2_UNDER_CONCERT_BRIDGE = 1212, + NS_FLAG_COLLECTABLE_3_BY_FV_LAUNCH = 1213, + NS_FLAG_COLLECTABLE_4_IN_PLAZA_BEHIND_BUILDING = 1214, + NS_FLAG_COLLECTABLE_5_BY_GF_LAUNCH = 1215, + NS_FLAG_COLLECTABLE_6_BY_DUCK_SG = 1216, + NS_FLAG_COLLECTABLE_7_BY_LUP_LAUNCH = 1217, + NS_FLAG_COLLECTABLE_8_BY_NT_LUANCH = 1218, + NS_FLAG_COLLECTABLE_9_BY_RACE_BUILD = 1219, + NS_FLAG_COLLECTABLE_10_ON_AG_LAUNCH_PATH = 1220, + PR_BINOC_AT_LAUNCH_PAD = 1251, + PR_BINOC_AT_BEGINNING_OF_ISLAND_B = 1252, + PR_BINOC_AT_FIRST_PET_BOUNCER = 1253, + PR_BINOC_ON_BY_CROWS_NEST = 1254, + PR_PET_DIG_AT_BEGINNING_OF_ISLAND_B = 1261, + PR_PET_DIG_AT_THE_LOCATION_OF_OLD_BOUNCE_BACK = 1262, + PR_PET_DIG_UNDER_QB_BRIDGE = 1263, + PR_PET_DIG_BACK_SIDE_BY_PARTNER_BOUNCE = 1264, + PR_PET_DIG_BY_LAUNCH_PAD = 1265, + PR_PET_DIG_BY_FIRST_PET_BOUNCER = 1266, + GF_BINOC_ON_LANDING_PAD = 1301, + GF_BINOC_AT_RAVINE_START = 1302, + GF_BINOC_ON_TOP_OF_RAVINE_HEAD = 1303, + GF_BINOC_AT_TURTLE_AREA = 1304, + GF_BINOC_IN_TUNNEL_TO_ELEPHANTS = 1305, + GF_BINOC_IN_ELEPHANTS_AREA = 1306, + GF_BINOC_IN_RACING_AREA = 1307, + GF_BINOC_IN_CROC_AREA = 1308, + GF_BINOC_IN_JAIL_AREA = 1309, + GF_BINOC_TELESCOPE_NEXT_TO_CAPTAIN_JACK = 1310, + NT_HEART_OF_DARKNESS = 1911, + NT_PLINTH_REBUILD = 1919, + NT_FACTION_SPY_DUKE = 1974, + NT_FACTION_SPY_OVERBUILD = 1976, + NT_FACTION_SPY_HAEL = 1977, + NJ_EARTH_SPINJITZU = 2030, + NJ_LIGHTNING_SPINJITZU = 2031, + NJ_ICE_SPINJITZU = 2032, + NJ_FIRE_SPINJITZU = 2033, + NJ_WU_SHOW_DAILY_CHEST = 2099 +}; + +#endif //!__EPLAYERFLAG__H__ diff --git a/dCommon/dEnums/eQuickBuildFailReason.h b/dCommon/dEnums/eQuickBuildFailReason.h new file mode 100644 index 00000000..a6144bd5 --- /dev/null +++ b/dCommon/dEnums/eQuickBuildFailReason.h @@ -0,0 +1,13 @@ +#ifndef __EQUICKBUILDFAILREASON__H__ +#define __EQUICKBUILDFAILREASON__H__ + +#include + +enum class eQuickBuildFailReason : uint32_t { + NOT_GIVEN, + OUT_OF_IMAGINATION, + CANCELED_EARLY, + BUILD_ENDED +}; + +#endif //!__EQUICKBUILDFAILREASON__H__ diff --git a/dCommon/dEnums/eRebuildState.h b/dCommon/dEnums/eRebuildState.h new file mode 100644 index 00000000..497bcb77 --- /dev/null +++ b/dCommon/dEnums/eRebuildState.h @@ -0,0 +1,15 @@ +#ifndef __EREBUILDSTATE__H__ +#define __EREBUILDSTATE__H__ + +#include + +enum class eRebuildState : uint32_t { + OPEN, + COMPLETED = 2, + RESETTING = 4, + BUILDING, + INCOMPLETE +}; + + +#endif //!__EREBUILDSTATE__H__ diff --git a/dCommon/dEnums/eRenameResponse.h b/dCommon/dEnums/eRenameResponse.h new file mode 100644 index 00000000..2298e922 --- /dev/null +++ b/dCommon/dEnums/eRenameResponse.h @@ -0,0 +1,15 @@ +#ifndef __ERENAMERESPONSE__H__ +#define __ERENAMERESPONSE__H__ + +#include + +//! An enum for character rename responses +enum class eRenameResponse : uint8_t { + SUCCESS = 0, + UNKNOWN_ERROR, + NAME_UNAVAILABLE, + NAME_IN_USE +}; + + +#endif //!__ERENAMERESPONSE__H__ diff --git a/dCommon/dEnums/eReplicaComponentType.h b/dCommon/dEnums/eReplicaComponentType.h index 3eee16f3..2d24c19e 100644 --- a/dCommon/dEnums/eReplicaComponentType.h +++ b/dCommon/dEnums/eReplicaComponentType.h @@ -107,7 +107,7 @@ enum class eReplicaComponentType : uint32_t { DONATION_VENDOR, COMBAT_MEDIATOR, COMMENDATION_VENDOR, - UNKNOWN_103, + GATE_RUSH_CONTROL, RAIL_ACTIVATOR, ROLLER, PLAYER_FORCED_MOVEMENT, @@ -119,7 +119,7 @@ enum class eReplicaComponentType : uint32_t { UNKNOWN_112, PROPERTY_PLAQUE, BUILD_BORDER, - UNKOWN_115, + UNKNOWN_115, CULLING_PLANE, DESTROYABLE = 1000 // Actually 7 }; diff --git a/dCommon/dEnums/eReplicaPacketType.h b/dCommon/dEnums/eReplicaPacketType.h new file mode 100644 index 00000000..2650fb30 --- /dev/null +++ b/dCommon/dEnums/eReplicaPacketType.h @@ -0,0 +1,12 @@ +#ifndef __EREPLICAPACKETTYPE__H__ +#define __EREPLICAPACKETTYPE__H__ + +#include + +enum class eReplicaPacketType : uint8_t { + CONSTRUCTION, + SERIALIZATION, + DESTRUCTION +}; + +#endif //!__EREPLICAPACKETTYPE__H__ diff --git a/dCommon/dEnums/eServerMessageType.h b/dCommon/dEnums/eServerMessageType.h new file mode 100644 index 00000000..7f211ffb --- /dev/null +++ b/dCommon/dEnums/eServerMessageType.h @@ -0,0 +1,12 @@ +#ifndef __ESERVERMESSAGETYPE__H__ +#define __ESERVERMESSAGETYPE__H__ + +#include +//! The Internal Server Packet Identifiers +enum class eServerMessageType : uint32_t { + VERSION_CONFIRM = 0, + DISCONNECT_NOTIFY, + GENERAL_NOTIFY +}; + +#endif //!__ESERVERMESSAGETYPE__H__ diff --git a/dCommon/dEnums/eStateChangeType.h b/dCommon/dEnums/eStateChangeType.h new file mode 100644 index 00000000..e187e265 --- /dev/null +++ b/dCommon/dEnums/eStateChangeType.h @@ -0,0 +1,11 @@ +#ifndef __ESTATECHANGETYPE__H__ +#define __ESTATECHANGETYPE__H__ + +#include + +enum class eStateChangeType : uint32_t { + PUSH, + POP +}; + +#endif //!__ESTATECHANGETYPE__H__ diff --git a/dCommon/dEnums/eTerminateType.h b/dCommon/dEnums/eTerminateType.h new file mode 100644 index 00000000..189734f8 --- /dev/null +++ b/dCommon/dEnums/eTerminateType.h @@ -0,0 +1,12 @@ +#ifndef __ETERMINATETYPE__H__ +#define __ETERMINATETYPE__H__ + +#include + +enum class eTerminateType : uint32_t { + RANGE, + USER, + FROM_INTERACTION +}; + +#endif //!__ETERMINATETYPE__H__ diff --git a/dCommon/dEnums/eUseItemResponse.h b/dCommon/dEnums/eUseItemResponse.h new file mode 100644 index 00000000..ba0ece7f --- /dev/null +++ b/dCommon/dEnums/eUseItemResponse.h @@ -0,0 +1,12 @@ +#ifndef __EUSEITEMRESPONSE__H__ +#define __EUSEITEMRESPONSE__H__ + +#include + +enum class eUseItemResponse : uint32_t { + NoImaginationForPet = 1, + FailedPrecondition, + MountsNotAllowed +}; + +#endif //!__EUSEITEMRESPONSE__H__ diff --git a/dCommon/dEnums/eWorldMessageType.h b/dCommon/dEnums/eWorldMessageType.h new file mode 100644 index 00000000..2a65fd98 --- /dev/null +++ b/dCommon/dEnums/eWorldMessageType.h @@ -0,0 +1,42 @@ +#ifndef __EWORLDMESSAGETYPE__H__ +#define __EWORLDMESSAGETYPE__H__ + +#include + +enum class eWorldMessageType : uint32_t { + VALIDATION = 1, // Session info + CHARACTER_LIST_REQUEST, + CHARACTER_CREATE_REQUEST, + LOGIN_REQUEST, // Character selected + GAME_MSG, + CHARACTER_DELETE_REQUEST, + CHARACTER_RENAME_REQUEST, + HAPPY_FLOWER_MODE_NOTIFY, + SLASH_RELOAD_MAP, // Reload map cmp + SLASH_PUSH_MAP_REQUEST, // Push map req cmd + SLASH_PUSH_MAP, // Push map cmd + SLASH_PULL_MAP, // Pull map cmd + LOCK_MAP_REQUEST, + GENERAL_CHAT_MESSAGE, // General chat message + HTTP_MONITOR_INFO_REQUEST, + SLASH_DEBUG_SCRIPTS, // Debug scripts cmd + MODELS_CLEAR, + EXHIBIT_INSERT_MODEL, + LEVEL_LOAD_COMPLETE, // Character data request + TMP_GUILD_CREATE, + ROUTE_PACKET, // Social? + POSITION_UPDATE, + MAIL, + WORD_CHECK, // Whitelist word check + STRING_CHECK, // Whitelist string check + GET_PLAYERS_IN_ZONE, + REQUEST_UGC_MANIFEST_INFO, + BLUEPRINT_GET_ALL_DATA_REQUEST, + CANCEL_MAP_QUEUE, + HANDLE_FUNNESS, + FAKE_PRG_CSR_MESSAGE, + REQUEST_FREE_TRIAL_REFRESH, + GM_SET_FREE_TRIAL_STATUS +}; + +#endif //!__EWORLDMESSAGETYPE__H__ diff --git a/dGame/Character.cpp b/dGame/Character.cpp index b8d08854..319b9376 100644 --- a/dGame/Character.cpp +++ b/dGame/Character.cpp @@ -18,7 +18,9 @@ #include "InventoryComponent.h" #include "eMissionTaskType.h" #include "eMissionState.h" +#include "eObjectBits.h" #include "eGameMasterLevel.h" +#include "ePlayerFlag.h" Character::Character(uint32_t id, User* parentUser) { //First load the name, etc: @@ -69,8 +71,8 @@ Character::Character(uint32_t id, User* parentUser) { //Set our objectID: m_ObjectID = m_ID; - m_ObjectID = GeneralUtils::SetBit(m_ObjectID, OBJECT_BIT_CHARACTER); - m_ObjectID = GeneralUtils::SetBit(m_ObjectID, OBJECT_BIT_PERSISTENT); + GeneralUtils::SetBit(m_ObjectID, eObjectBits::CHARACTER); + GeneralUtils::SetBit(m_ObjectID, eObjectBits::PERSISTENT); m_ParentUser = parentUser; m_OurEntity = nullptr; @@ -128,8 +130,8 @@ void Character::UpdateFromDatabase() { //Set our objectID: m_ObjectID = m_ID; - m_ObjectID = GeneralUtils::SetBit(m_ObjectID, OBJECT_BIT_CHARACTER); - m_ObjectID = GeneralUtils::SetBit(m_ObjectID, OBJECT_BIT_PERSISTENT); + GeneralUtils::SetBit(m_ObjectID, eObjectBits::CHARACTER); + GeneralUtils::SetBit(m_ObjectID, eObjectBits::PERSISTENT); m_OurEntity = nullptr; m_BuildMode = false; @@ -361,9 +363,9 @@ void Character::SaveXMLToDatabase() { } // Prevents the news feed from showing up on world transfers - if (GetPlayerFlag(ePlayerFlags::IS_NEWS_SCREEN_VISIBLE)) { + if (GetPlayerFlag(ePlayerFlag::IS_NEWS_SCREEN_VISIBLE)) { auto* s = m_Doc->NewElement("s"); - s->SetAttribute("si", ePlayerFlags::IS_NEWS_SCREEN_VISIBLE); + s->SetAttribute("si", ePlayerFlag::IS_NEWS_SCREEN_VISIBLE); flags->LinkEndChild(s); } @@ -371,7 +373,7 @@ void Character::SaveXMLToDatabase() { //Call upon the entity to update our xmlDoc: if (!m_OurEntity) { - Game::logger->Log("Character", "We didn't have an entity set while saving! CHARACTER WILL NOT BE SAVED!"); + Game::logger->Log("Character", "%i:%s didn't have an entity set while saving! CHARACTER WILL NOT BE SAVED!", this->GetID(), this->GetName().c_str()); return; } @@ -382,7 +384,7 @@ void Character::SaveXMLToDatabase() { //For metrics, log the time it took to save: auto end = std::chrono::system_clock::now(); std::chrono::duration elapsed = end - start; - Game::logger->Log("Character", "Saved character to Database in: %fs", elapsed.count()); + Game::logger->Log("Character", "%i:%s Saved character to Database in: %fs", this->GetID(), this->GetName().c_str(), elapsed.count()); } void Character::SetIsNewLogin() { @@ -394,7 +396,7 @@ void Character::SetIsNewLogin() { while (currentChild) { if (currentChild->Attribute("si")) { flags->DeleteChild(currentChild); - Game::logger->Log("Character", "Removed isLoggedIn flag from character %i, saving character to database", GetID()); + Game::logger->Log("Character", "Removed isLoggedIn flag from character %i:%s, saving character to database", GetID(), GetName().c_str()); WriteToDatabase(); } currentChild = currentChild->NextSiblingElement(); @@ -416,7 +418,7 @@ void Character::WriteToDatabase() { delete printer; } -void Character::SetPlayerFlag(const uint32_t flagId, const bool value) { +void Character::SetPlayerFlag(const int32_t flagId, const bool value) { // If the flag is already set, we don't have to recalculate it if (GetPlayerFlag(flagId) == value) return; @@ -463,7 +465,7 @@ void Character::SetPlayerFlag(const uint32_t flagId, const bool value) { GameMessages::SendNotifyClientFlagChange(m_ObjectID, flagId, value, m_ParentUser->GetSystemAddress()); } -bool Character::GetPlayerFlag(const uint32_t flagId) const { +bool Character::GetPlayerFlag(const int32_t flagId) const { // Calculate the index first const auto flagIndex = uint32_t(std::floor(flagId / 64)); @@ -480,8 +482,8 @@ bool Character::GetPlayerFlag(const uint32_t flagId) const { void Character::SetRetroactiveFlags() { // Retroactive check for if player has joined a faction to set their 'joined a faction' flag to true. - if (GetPlayerFlag(ePlayerFlags::VENTURE_FACTION) || GetPlayerFlag(ePlayerFlags::ASSEMBLY_FACTION) || GetPlayerFlag(ePlayerFlags::PARADOX_FACTION) || GetPlayerFlag(ePlayerFlags::SENTINEL_FACTION)) { - SetPlayerFlag(ePlayerFlags::JOINED_A_FACTION, true); + if (GetPlayerFlag(ePlayerFlag::VENTURE_FACTION) || GetPlayerFlag(ePlayerFlag::ASSEMBLY_FACTION) || GetPlayerFlag(ePlayerFlag::PARADOX_FACTION) || GetPlayerFlag(ePlayerFlag::SENTINEL_FACTION)) { + SetPlayerFlag(ePlayerFlag::JOINED_A_FACTION, true); } } @@ -541,7 +543,7 @@ void Character::OnZoneLoad() { if (missionComponent != nullptr) { // Fix the monument race flag if (missionComponent->GetMissionState(319) >= eMissionState::READY_TO_COMPLETE) { - SetPlayerFlag(33, true); + SetPlayerFlag(ePlayerFlag::AG_FINISH_LINE_BUILT, true); } } @@ -557,7 +559,7 @@ void Character::OnZoneLoad() { */ if (HasPermission(ePermissionMap::Old)) { if (GetCoins() > 1000000) { - SetCoins(1000000, eLootSourceType::LOOT_SOURCE_NONE); + SetCoins(1000000, eLootSourceType::NONE); } } @@ -635,7 +637,7 @@ void Character::SetBillboardVisible(bool visible) { // The GameMessage we send for turning the nameplate off just deletes the BillboardSubcomponent from the parent component. // Because that same message does not allow for custom parameters, we need to create the BillboardSubcomponent a different way - // This workaround involves sending an unrelated GameMessage that does not apply to player entites, + // This workaround involves sending an unrelated GameMessage that does not apply to player entites, // but forces the client to create the necessary SubComponent that controls the billboard. GameMessages::SendShowBillboardInteractIcon(UNASSIGNED_SYSTEM_ADDRESS, m_OurEntity->GetObjectID()); diff --git a/dGame/Character.h b/dGame/Character.h index 2f0abba5..3759f206 100644 --- a/dGame/Character.h +++ b/dGame/Character.h @@ -16,6 +16,7 @@ struct Packet; class Entity; enum class ePermissionMap : uint64_t; enum class eGameMasterLevel : uint8_t; +enum class eLootSourceType : uint32_t; /** * Meta information about a character, like their name and style @@ -414,14 +415,14 @@ public: * @param flagId the ID of the flag to set * @param value the value to set for the flag */ - void SetPlayerFlag(uint32_t flagId, bool value); + void SetPlayerFlag(int32_t flagId, bool value); /** * Gets the value for a certain character flag * @param flagId the ID of the flag to get a value for * @return the value of the flag given the ID (the default is false, obviously) */ - bool GetPlayerFlag(uint32_t flagId) const; + bool GetPlayerFlag(int32_t flagId) const; /** * Notifies the character that they're now muted diff --git a/dGame/Entity.cpp b/dGame/Entity.cpp index 1e03f108..6de6ba62 100644 --- a/dGame/Entity.cpp +++ b/dGame/Entity.cpp @@ -24,6 +24,7 @@ #include "Loot.h" #include "eMissionTaskType.h" #include "eTriggerEventType.h" +#include "eObjectBits.h" //Component includes: #include "Component.h" @@ -72,6 +73,7 @@ #include "TriggerComponent.h" #include "eGameMasterLevel.h" #include "eReplicaComponentType.h" +#include "eReplicaPacketType.h" // Table includes #include "CDComponentsRegistryTable.h" @@ -706,6 +708,13 @@ void Entity::Initialize() { // TODO: create movementAIcomp and set path } }*/ + } else { + // else we still need to setup moving platform if it has a moving platform comp but no path + int32_t movingPlatformComponentId = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::MOVING_PLATFORM, -1); + if (movingPlatformComponentId >= 0) { + MovingPlatformComponent* plat = new MovingPlatformComponent(this, pathName); + m_Components.insert(std::make_pair(eReplicaComponentType::MOVING_PLATFORM, plat)); + } } int proximityMonitorID = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::PROXIMITY_MONITOR); @@ -728,7 +737,7 @@ void Entity::Initialize() { if (!m_Character && EntityManager::Instance()->GetGhostingEnabled()) { // Don't ghost what is likely large scene elements - if (m_Components.size() == 2 && HasComponent(eReplicaComponentType::SIMPLE_PHYSICS) && HasComponent(eReplicaComponentType::RENDER)) { + if (HasComponent(eReplicaComponentType::SIMPLE_PHYSICS) && HasComponent(eReplicaComponentType::RENDER) && (m_Components.size() == 2 || (HasComponent(eReplicaComponentType::TRIGGER) && m_Components.size() == 3))) { goto no_ghosting; } @@ -876,7 +885,7 @@ void Entity::SetGMLevel(eGameMasterLevel value) { } void Entity::WriteBaseReplicaData(RakNet::BitStream* outBitStream, eReplicaPacketType packetType) { - if (packetType == PACKET_TYPE_CONSTRUCTION) { + if (packetType == eReplicaPacketType::CONSTRUCTION) { outBitStream->Write(m_ObjectID); outBitStream->Write(m_TemplateID); @@ -953,9 +962,9 @@ void Entity::WriteBaseReplicaData(RakNet::BitStream* outBitStream, eReplicaPacke if (m_ParentEntity != nullptr || m_SpawnerID != 0) { outBitStream->Write1(); - if (m_ParentEntity != nullptr) outBitStream->Write(GeneralUtils::SetBit(m_ParentEntity->GetObjectID(), OBJECT_BIT_CLIENT)); + if (m_ParentEntity != nullptr) outBitStream->Write(GeneralUtils::SetBit(m_ParentEntity->GetObjectID(), static_cast(eObjectBits::CLIENT))); else if (m_Spawner != nullptr && m_Spawner->m_Info.isNetwork) outBitStream->Write(m_SpawnerID); - else outBitStream->Write(GeneralUtils::SetBit(m_SpawnerID, OBJECT_BIT_CLIENT)); + else outBitStream->Write(GeneralUtils::SetBit(m_SpawnerID, static_cast(eObjectBits::CLIENT))); } else outBitStream->Write0(); outBitStream->Write(m_HasSpawnerNodeID); @@ -978,8 +987,8 @@ void Entity::WriteBaseReplicaData(RakNet::BitStream* outBitStream, eReplicaPacke } // Only serialize parent / child info should the info be dirty (changed) or if this is the construction of the entity. - outBitStream->Write(m_IsParentChildDirty || packetType == PACKET_TYPE_CONSTRUCTION); - if (m_IsParentChildDirty || packetType == PACKET_TYPE_CONSTRUCTION) { + outBitStream->Write(m_IsParentChildDirty || packetType == eReplicaPacketType::CONSTRUCTION); + if (m_IsParentChildDirty || packetType == eReplicaPacketType::CONSTRUCTION) { m_IsParentChildDirty = false; outBitStream->Write(m_ParentEntity != nullptr); if (m_ParentEntity) { @@ -1004,7 +1013,7 @@ void Entity::WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType bool destroyableSerialized = false; bool bIsInitialUpdate = false; - if (packetType == PACKET_TYPE_CONSTRUCTION) bIsInitialUpdate = true; + if (packetType == eReplicaPacketType::CONSTRUCTION) bIsInitialUpdate = true; unsigned int flags = 0; PossessableComponent* possessableComponent; @@ -1233,6 +1242,7 @@ void Entity::Update(const float deltaTime) { for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) { script->OnTimerDone(this, timerName); } + TriggerEvent(eTriggerEventType::TIMER_DONE, this); } else { timerPosition++; } @@ -1343,6 +1353,10 @@ void Entity::OnCollisionLeavePhantom(const LWOOBJID otherEntity) { auto* other = EntityManager::Instance()->GetEntity(otherEntity); if (!other) return; + for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) { + script->OnOffCollisionPhantom(this, other); + } + TriggerEvent(eTriggerEventType::EXIT, other); SwitchComponent* switchComp = GetComponent(); @@ -1479,6 +1493,12 @@ void Entity::OnChoiceBoxResponse(Entity* sender, int32_t button, const std::u16s } } +void Entity::RequestActivityExit(Entity* sender, LWOOBJID player, bool canceled) { + for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) { + script->OnRequestActivityExit(sender, player, canceled); + } +} + void Entity::Smash(const LWOOBJID source, const eKillType killType, const std::u16string& deathType) { if (!m_PlayerIsReadyForUpdates) return; @@ -1619,7 +1639,7 @@ void Entity::PickupItem(const LWOOBJID& objectID) { } } } else { - inv->AddItem(p.second.lot, p.second.count, eLootSourceType::LOOT_SOURCE_PICKUP, eInventoryType::INVALID, {}, LWOOBJID_EMPTY, true, false, LWOOBJID_EMPTY, eInventoryType::INVALID, 1); + inv->AddItem(p.second.lot, p.second.count, eLootSourceType::PICKUP, eInventoryType::INVALID, {}, LWOOBJID_EMPTY, true, false, LWOOBJID_EMPTY, eInventoryType::INVALID, 1); } } } diff --git a/dGame/Entity.h b/dGame/Entity.h index f8abff31..90f2a34f 100644 --- a/dGame/Entity.h +++ b/dGame/Entity.h @@ -10,6 +10,7 @@ #include "NiPoint3.h" #include "NiQuaternion.h" #include "LDFFormat.h" +#include "eKillType.h" namespace Loot { class Info; @@ -33,6 +34,8 @@ class EntityCallbackTimer; enum class eTriggerEventType; enum class eGameMasterLevel : uint8_t; enum class eReplicaComponentType : uint32_t; +enum class eReplicaPacketType : uint8_t; +enum class eCinematicEvent : uint32_t; namespace CppScripts { class Script; @@ -204,6 +207,7 @@ public: void OnMessageBoxResponse(Entity* sender, int32_t button, const std::u16string& identifier, const std::u16string& userData); void OnChoiceBoxResponse(Entity* sender, int32_t button, const std::u16string& buttonIdentifier, const std::u16string& identifier); + void RequestActivityExit(Entity* sender, LWOOBJID player, bool canceled); void Smash(const LWOOBJID source = LWOOBJID_EMPTY, const eKillType killType = eKillType::VIOLENT, const std::u16string& deathType = u""); void Kill(Entity* murderer = nullptr); diff --git a/dGame/EntityManager.cpp b/dGame/EntityManager.cpp index d547cdb1..0fc859bd 100644 --- a/dGame/EntityManager.cpp +++ b/dGame/EntityManager.cpp @@ -20,8 +20,10 @@ #include "MessageIdentifiers.h" #include "dConfig.h" #include "eTriggerEventType.h" +#include "eObjectBits.h" #include "eGameMasterLevel.h" #include "eReplicaComponentType.h" +#include "eReplicaPacketType.h" EntityManager* EntityManager::m_Address = nullptr; @@ -108,11 +110,11 @@ Entity* EntityManager::CreateEntity(EntityInfo info, User* user, Entity* parentE if (!controller && info.lot != 14) { // The client flags means the client should render the entity - id = GeneralUtils::SetBit(id, OBJECT_BIT_CLIENT); + GeneralUtils::SetBit(id, eObjectBits::CLIENT); // Spawned entities require the spawned flag to render if (info.spawnerID != 0) { - id = GeneralUtils::SetBit(id, OBJECT_BIT_SPAWNED); + GeneralUtils::SetBit(id, eObjectBits::SPAWNED); } } } @@ -159,9 +161,7 @@ void EntityManager::DestroyEntity(const LWOOBJID& objectID) { } void EntityManager::DestroyEntity(Entity* entity) { - if (entity == nullptr) { - return; - } + if (!entity) return; entity->TriggerEvent(eTriggerEventType::DESTROY, entity); @@ -180,15 +180,11 @@ void EntityManager::DestroyEntity(Entity* entity) { ScheduleForDeletion(id); } -void EntityManager::UpdateEntities(const float deltaTime) { - for (const auto& e : m_Entities) { - e.second->Update(deltaTime); - } - +void EntityManager::SerializeEntities() { for (auto entry = m_EntitiesToSerialize.begin(); entry != m_EntitiesToSerialize.end(); entry++) { auto* entity = GetEntity(*entry); - if (entity == nullptr) continue; + if (!entity) continue; m_SerializationCounter++; @@ -196,8 +192,8 @@ void EntityManager::UpdateEntities(const float deltaTime) { stream.Write(static_cast(ID_REPLICA_MANAGER_SERIALIZE)); stream.Write(static_cast(entity->GetNetworkId())); - entity->WriteBaseReplicaData(&stream, PACKET_TYPE_SERIALIZATION); - entity->WriteComponents(&stream, PACKET_TYPE_SERIALIZATION); + entity->WriteBaseReplicaData(&stream, eReplicaPacketType::SERIALIZATION); + entity->WriteComponents(&stream, eReplicaPacketType::SERIALIZATION); if (entity->GetIsGhostingCandidate()) { for (auto* player : Player::GetAllPlayers()) { @@ -210,45 +206,59 @@ void EntityManager::UpdateEntities(const float deltaTime) { } } m_EntitiesToSerialize.clear(); +} +void EntityManager::KillEntities() { for (auto entry = m_EntitiesToKill.begin(); entry != m_EntitiesToKill.end(); entry++) { auto* entity = GetEntity(*entry); - if (!entity) continue; + if (!entity) { + Game::logger->Log("EntityManager", "Attempting to kill null entity %llu", *entry); + continue; + } if (entity->GetScheduledKiller()) { - entity->Smash(entity->GetScheduledKiller()->GetObjectID(), SILENT); + entity->Smash(entity->GetScheduledKiller()->GetObjectID(), eKillType::SILENT); } else { - entity->Smash(LWOOBJID_EMPTY, SILENT); + entity->Smash(LWOOBJID_EMPTY, eKillType::SILENT); } } m_EntitiesToKill.clear(); +} +void EntityManager::DeleteEntities() { for (auto entry = m_EntitiesToDelete.begin(); entry != m_EntitiesToDelete.end(); entry++) { - - // Get all this info first before we delete the player. auto entityToDelete = GetEntity(*entry); - auto networkIdToErase = entityToDelete->GetNetworkId(); - const auto& ghostingToDelete = std::find(m_EntitiesToGhost.begin(), m_EntitiesToGhost.end(), entityToDelete); - if (entityToDelete) { - // If we are a player run through the player destructor. - if (entityToDelete->IsPlayer()) { - delete dynamic_cast(entityToDelete); - } else { - delete entityToDelete; - } + // Get all this info first before we delete the player. + auto networkIdToErase = entityToDelete->GetNetworkId(); + const auto& ghostingToDelete = std::find(m_EntitiesToGhost.begin(), m_EntitiesToGhost.end(), entityToDelete); + + delete entityToDelete; + entityToDelete = nullptr; + if (networkIdToErase != 0) m_LostNetworkIds.push(networkIdToErase); + + if (ghostingToDelete != m_EntitiesToGhost.end()) m_EntitiesToGhost.erase(ghostingToDelete); + } else { + Game::logger->Log("EntityManager", "Attempted to delete non-existent entity %llu", *entry); } - - if (ghostingToDelete != m_EntitiesToGhost.end()) m_EntitiesToGhost.erase(ghostingToDelete); - m_Entities.erase(*entry); } m_EntitiesToDelete.clear(); } +void EntityManager::UpdateEntities(const float deltaTime) { + for (const auto& e : m_Entities) { + e.second->Update(deltaTime); + } + + SerializeEntities(); + KillEntities(); + DeleteEntities(); +} + Entity* EntityManager::GetEntity(const LWOOBJID& objectId) const { const auto& index = m_Entities.find(objectId); @@ -314,6 +324,11 @@ const std::unordered_map& EntityManager::GetSpawnPointEnt } void EntityManager::ConstructEntity(Entity* entity, const SystemAddress& sysAddr, const bool skipChecks) { + if (!entity) { + Game::logger->Log("EntityManager", "Attempted to construct null entity"); + return; + } + if (entity->GetNetworkId() == 0) { uint16_t networkId; @@ -351,8 +366,8 @@ void EntityManager::ConstructEntity(Entity* entity, const SystemAddress& sysAddr stream.Write(true); stream.Write(static_cast(entity->GetNetworkId())); - entity->WriteBaseReplicaData(&stream, PACKET_TYPE_CONSTRUCTION); - entity->WriteComponents(&stream, PACKET_TYPE_CONSTRUCTION); + entity->WriteBaseReplicaData(&stream, eReplicaPacketType::CONSTRUCTION); + entity->WriteComponents(&stream, eReplicaPacketType::CONSTRUCTION); if (sysAddr == UNASSIGNED_SYSTEM_ADDRESS) { if (skipChecks) { @@ -393,9 +408,7 @@ void EntityManager::ConstructAllEntities(const SystemAddress& sysAddr) { } void EntityManager::DestructEntity(Entity* entity, const SystemAddress& sysAddr) { - if (entity->GetNetworkId() == 0) { - return; - } + if (!entity || entity->GetNetworkId() == 0) return; RakNet::BitStream stream; @@ -412,9 +425,7 @@ void EntityManager::DestructEntity(Entity* entity, const SystemAddress& sysAddr) } void EntityManager::SerializeEntity(Entity* entity) { - if (entity->GetNetworkId() == 0) { - return; - } + if (!entity || entity->GetNetworkId() == 0) return; if (std::find(m_EntitiesToSerialize.begin(), m_EntitiesToSerialize.end(), entity->GetObjectID()) == m_EntitiesToSerialize.end()) { m_EntitiesToSerialize.push_back(entity->GetObjectID()); diff --git a/dGame/EntityManager.h b/dGame/EntityManager.h index 0314cc09..b524344c 100644 --- a/dGame/EntityManager.h +++ b/dGame/EntityManager.h @@ -85,6 +85,10 @@ public: const uint32_t GetHardcoreUscoreEnemiesMultiplier() { return m_HardcoreUscoreEnemiesMultiplier; }; private: + void SerializeEntities(); + void KillEntities(); + void DeleteEntities(); + static EntityManager* m_Address; //For singleton method static std::vector m_GhostingExcludedZones; static std::vector m_GhostingExcludedLOTs; diff --git a/dGame/TradingManager.cpp b/dGame/TradingManager.cpp index e1eac422..281c003d 100644 --- a/dGame/TradingManager.cpp +++ b/dGame/TradingManager.cpp @@ -156,21 +156,21 @@ void Trade::Complete() { } // Now actually do the 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); + characterA->SetCoins(characterA->GetCoins() - m_CoinsA + m_CoinsB, eLootSourceType::TRADE); + characterB->SetCoins(characterB->GetCoins() - m_CoinsB + m_CoinsA, eLootSourceType::TRADE); for (const auto& tradeItem : m_ItemsA) { auto* itemToRemove = inventoryA->FindItemById(tradeItem.itemId); if (itemToRemove) itemToRemove->SetCount(itemToRemove->GetCount() - tradeItem.itemCount); missionsA->Progress(eMissionTaskType::GATHER, tradeItem.itemLot, LWOOBJID_EMPTY, "", -tradeItem.itemCount); - inventoryB->AddItem(tradeItem.itemLot, tradeItem.itemCount, eLootSourceType::LOOT_SOURCE_TRADE); + inventoryB->AddItem(tradeItem.itemLot, tradeItem.itemCount, eLootSourceType::TRADE); } for (const auto& tradeItem : m_ItemsB) { auto* itemToRemove = inventoryB->FindItemById(tradeItem.itemId); if (itemToRemove) itemToRemove->SetCount(itemToRemove->GetCount() - tradeItem.itemCount); missionsB->Progress(eMissionTaskType::GATHER, tradeItem.itemLot, LWOOBJID_EMPTY, "", -tradeItem.itemCount); - inventoryA->AddItem(tradeItem.itemLot, tradeItem.itemCount, eLootSourceType::LOOT_SOURCE_TRADE); + inventoryA->AddItem(tradeItem.itemLot, tradeItem.itemCount, eLootSourceType::TRADE); } characterA->SaveXMLToDatabase(); diff --git a/dGame/UserManager.cpp b/dGame/UserManager.cpp index 4f0c456d..0161395c 100644 --- a/dGame/UserManager.cpp +++ b/dGame/UserManager.cpp @@ -22,8 +22,12 @@ #include "SkillComponent.h" #include "AssetManager.h" #include "CDClientDatabase.h" -#include "dMessageIdentifiers.h" +#include "eObjectBits.h" #include "eGameMasterLevel.h" +#include "eCharacterCreationResponse.h" +#include "eRenameResponse.h" +#include "eConnectionType.h" +#include "eChatInternalMessageType.h" UserManager* UserManager::m_Address = nullptr; @@ -268,13 +272,13 @@ void UserManager::CreateCharacter(const SystemAddress& sysAddr, Packet* packet) if (name != "" && !UserManager::IsNameAvailable(name)) { Game::logger->Log("UserManager", "AccountID: %i chose unavailable name: %s", u->GetAccountID(), name.c_str()); - WorldPackets::SendCharacterCreationResponse(sysAddr, CREATION_RESPONSE_CUSTOM_NAME_IN_USE); + WorldPackets::SendCharacterCreationResponse(sysAddr, eCharacterCreationResponse::CUSTOM_NAME_IN_USE); return; } if (!IsNameAvailable(predefinedName)) { Game::logger->Log("UserManager", "AccountID: %i chose unavailable predefined name: %s", u->GetAccountID(), predefinedName.c_str()); - WorldPackets::SendCharacterCreationResponse(sysAddr, CREATION_RESPONSE_PREDEFINED_NAME_IN_USE); + WorldPackets::SendCharacterCreationResponse(sysAddr, eCharacterCreationResponse::PREDEFINED_NAME_IN_USE); return; } @@ -293,7 +297,7 @@ void UserManager::CreateCharacter(const SystemAddress& sysAddr, Packet* packet) if (overlapResult->next()) { Game::logger->Log("UserManager", "Character object id unavailable, check objectidtracker!"); - WorldPackets::SendCharacterCreationResponse(sysAddr, CREATION_RESPONSE_OBJECT_ID_UNAVAILABLE); + WorldPackets::SendCharacterCreationResponse(sysAddr, eCharacterCreationResponse::OBJECT_ID_UNAVAILABLE); return; } @@ -313,16 +317,16 @@ void UserManager::CreateCharacter(const SystemAddress& sysAddr, Packet* packet) std::stringstream xml2; LWOOBJID lwoidforshirt = idforshirt; - lwoidforshirt = GeneralUtils::SetBit(lwoidforshirt, OBJECT_BIT_CHARACTER); - lwoidforshirt = GeneralUtils::SetBit(lwoidforshirt, OBJECT_BIT_PERSISTENT); + GeneralUtils::SetBit(lwoidforshirt, eObjectBits::CHARACTER); + GeneralUtils::SetBit(lwoidforshirt, eObjectBits::PERSISTENT); xml2 << xmlSave1 << ""; std::string xmlSave2 = xml2.str(); ObjectIDManager::Instance()->RequestPersistentID([=](uint32_t idforpants) { LWOOBJID lwoidforpants = idforpants; - lwoidforpants = GeneralUtils::SetBit(lwoidforpants, OBJECT_BIT_CHARACTER); - lwoidforpants = GeneralUtils::SetBit(lwoidforpants, OBJECT_BIT_PERSISTENT); + GeneralUtils::SetBit(lwoidforpants, eObjectBits::CHARACTER); + GeneralUtils::SetBit(lwoidforpants, eObjectBits::PERSISTENT); std::stringstream xml3; xml3 << xmlSave2 << ""; @@ -369,7 +373,7 @@ void UserManager::CreateCharacter(const SystemAddress& sysAddr, Packet* packet) stmt->execute(); delete stmt; - WorldPackets::SendCharacterCreationResponse(sysAddr, CREATION_RESPONSE_SUCCESS); + WorldPackets::SendCharacterCreationResponse(sysAddr, eCharacterCreationResponse::SUCCESS); UserManager::RequestCharacterList(sysAddr); }); }); @@ -419,7 +423,7 @@ void UserManager::DeleteCharacter(const SystemAddress& sysAddr, Packet* packet) stmt->execute(); delete stmt; CBITSTREAM; - PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_PLAYER_REMOVED_NOTIFICATION); + PacketUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::PLAYER_REMOVED_NOTIFICATION); bitStream.Write(objectID); Game::chatServer->Send(&bitStream, SYSTEM_PRIORITY, RELIABLE, 0, Game::chatSysAddr, false); } @@ -480,8 +484,8 @@ void UserManager::RenameCharacter(const SystemAddress& sysAddr, Packet* packet) } LWOOBJID objectID = PacketUtils::ReadPacketS64(8, packet); - objectID = GeneralUtils::ClearBit(objectID, OBJECT_BIT_CHARACTER); - objectID = GeneralUtils::ClearBit(objectID, OBJECT_BIT_PERSISTENT); + GeneralUtils::ClearBit(objectID, eObjectBits::CHARACTER); + GeneralUtils::ClearBit(objectID, eObjectBits::PERSISTENT); uint32_t charID = static_cast(objectID); Game::logger->Log("UserManager", "Received char rename request for ID: %llu (%u)", objectID, charID); @@ -499,10 +503,10 @@ void UserManager::RenameCharacter(const SystemAddress& sysAddr, Packet* packet) if (!hasCharacter || !character) { Game::logger->Log("UserManager", "User %i tried to rename a character that it does not own!", u->GetAccountID()); - WorldPackets::SendCharacterRenameResponse(sysAddr, RENAME_RESPONSE_UNKNOWN_ERROR); + WorldPackets::SendCharacterRenameResponse(sysAddr, eRenameResponse::UNKNOWN_ERROR); } else if (hasCharacter && character) { if (newName == character->GetName()) { - WorldPackets::SendCharacterRenameResponse(sysAddr, RENAME_RESPONSE_NAME_UNAVAILABLE); + WorldPackets::SendCharacterRenameResponse(sysAddr, eRenameResponse::NAME_UNAVAILABLE); return; } @@ -516,7 +520,7 @@ void UserManager::RenameCharacter(const SystemAddress& sysAddr, Packet* packet) delete stmt; Game::logger->Log("UserManager", "Character %s now known as %s", character->GetName().c_str(), newName.c_str()); - WorldPackets::SendCharacterRenameResponse(sysAddr, RENAME_RESPONSE_SUCCESS); + WorldPackets::SendCharacterRenameResponse(sysAddr, eRenameResponse::SUCCESS); UserManager::RequestCharacterList(sysAddr); } else { sql::PreparedStatement* stmt = Database::CreatePreppedStmt("UPDATE charinfo SET pending_name=?, needs_rename=0, last_login=? WHERE id=? LIMIT 1"); @@ -527,15 +531,15 @@ void UserManager::RenameCharacter(const SystemAddress& sysAddr, Packet* packet) delete stmt; Game::logger->Log("UserManager", "Character %s has been renamed to %s and is pending approval by a moderator.", character->GetName().c_str(), newName.c_str()); - WorldPackets::SendCharacterRenameResponse(sysAddr, RENAME_RESPONSE_SUCCESS); + WorldPackets::SendCharacterRenameResponse(sysAddr, eRenameResponse::SUCCESS); UserManager::RequestCharacterList(sysAddr); } } else { - WorldPackets::SendCharacterRenameResponse(sysAddr, RENAME_RESPONSE_NAME_IN_USE); + WorldPackets::SendCharacterRenameResponse(sysAddr, eRenameResponse::NAME_IN_USE); } } else { Game::logger->Log("UserManager", "Unknown error occurred when renaming character, either hasCharacter or character variable != true."); - WorldPackets::SendCharacterRenameResponse(sysAddr, RENAME_RESPONSE_UNKNOWN_ERROR); + WorldPackets::SendCharacterRenameResponse(sysAddr, eRenameResponse::UNKNOWN_ERROR); } } diff --git a/dGame/dBehaviors/AirMovementBehavior.cpp b/dGame/dBehaviors/AirMovementBehavior.cpp index 932297b9..dbfde465 100644 --- a/dGame/dBehaviors/AirMovementBehavior.cpp +++ b/dGame/dBehaviors/AirMovementBehavior.cpp @@ -13,7 +13,7 @@ void AirMovementBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bi return; } - context->RegisterSyncBehavior(handle, this, branch); + context->RegisterSyncBehavior(handle, this, branch, this->m_Timeout); } void AirMovementBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { @@ -47,4 +47,5 @@ void AirMovementBehavior::Sync(BehaviorContext* context, RakNet::BitStream* bitS } void AirMovementBehavior::Load() { + this->m_Timeout = (GetFloat("timeout_ms") / 1000.0f); } diff --git a/dGame/dBehaviors/AirMovementBehavior.h b/dGame/dBehaviors/AirMovementBehavior.h index 89dc1e05..9d51ef03 100644 --- a/dGame/dBehaviors/AirMovementBehavior.h +++ b/dGame/dBehaviors/AirMovementBehavior.h @@ -4,13 +4,7 @@ class AirMovementBehavior final : public Behavior { public: - - /* - * 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; @@ -19,4 +13,6 @@ public: void Sync(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; void Load() override; +private: + float m_Timeout; }; diff --git a/dGame/dBehaviors/AttackDelayBehavior.cpp b/dGame/dBehaviors/AttackDelayBehavior.cpp index ccea5fd9..3f12f662 100644 --- a/dGame/dBehaviors/AttackDelayBehavior.cpp +++ b/dGame/dBehaviors/AttackDelayBehavior.cpp @@ -13,7 +13,7 @@ void AttackDelayBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bi }; for (auto i = 0u; i < this->m_numIntervals; ++i) { - context->RegisterSyncBehavior(handle, this, branch, m_ignoreInterrupts); + context->RegisterSyncBehavior(handle, this, branch, this->m_delay * i, m_ignoreInterrupts); } } diff --git a/dGame/dBehaviors/BasicAttackBehavior.cpp b/dGame/dBehaviors/BasicAttackBehavior.cpp index 97068d91..f8693795 100644 --- a/dGame/dBehaviors/BasicAttackBehavior.cpp +++ b/dGame/dBehaviors/BasicAttackBehavior.cpp @@ -147,7 +147,7 @@ void BasicAttackBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* DoBehaviorCalculation(context, bitStream, branch); const auto endAddress = bitStream->GetWriteOffset(); - const uint16_t allocate = endAddress - startAddress + 1; + const uint16_t allocate = endAddress - startAddress; bitStream->SetWriteOffset(allocatedAddress); bitStream->Write(allocate); diff --git a/dGame/dBehaviors/Behavior.cpp b/dGame/dBehaviors/Behavior.cpp index 2a269ddc..8b34507a 100644 --- a/dGame/dBehaviors/Behavior.cpp +++ b/dGame/dBehaviors/Behavior.cpp @@ -61,6 +61,7 @@ #include "SpeedBehavior.h" #include "DamageReductionBehavior.h" #include "JetPackBehavior.h" +#include "FallSpeedBehavior.h" #include "ChangeIdleFlagsBehavior.h" #include "DarkInspirationBehavior.h" @@ -164,7 +165,9 @@ Behavior* Behavior::CreateBehavior(const uint32_t behaviorId) { case BehaviorTemplates::BEHAVIOR_CAR_BOOST: behavior = new CarBoostBehavior(behaviorId); break; - case BehaviorTemplates::BEHAVIOR_FALL_SPEED: break; + case BehaviorTemplates::BEHAVIOR_FALL_SPEED: + behavior = new FallSpeedBehavior(behaviorId); + break; case BehaviorTemplates::BEHAVIOR_SHIELD: break; case BehaviorTemplates::BEHAVIOR_REPAIR_ARMOR: behavior = new RepairBehavior(behaviorId); diff --git a/dGame/dBehaviors/BehaviorContext.cpp b/dGame/dBehaviors/BehaviorContext.cpp index 397e0c72..c7db4208 100644 --- a/dGame/dBehaviors/BehaviorContext.cpp +++ b/dGame/dBehaviors/BehaviorContext.cpp @@ -10,12 +10,12 @@ #include -#include "dMessageIdentifiers.h" #include "DestroyableComponent.h" #include "EchoSyncSkill.h" #include "PhantomPhysicsComponent.h" #include "RebuildComponent.h" #include "eReplicaComponentType.h" +#include "eConnectionType.h" BehaviorSyncEntry::BehaviorSyncEntry() { } @@ -47,7 +47,7 @@ uint32_t BehaviorContext::GetUniqueSkillId() const { } -void BehaviorContext::RegisterSyncBehavior(const uint32_t syncId, Behavior* behavior, const BehaviorBranchContext& branchContext, bool ignoreInterrupts) { +void BehaviorContext::RegisterSyncBehavior(const uint32_t syncId, Behavior* behavior, const BehaviorBranchContext& branchContext, const float duration, bool ignoreInterrupts) { auto entry = BehaviorSyncEntry(); entry.handle = syncId; @@ -55,6 +55,9 @@ void BehaviorContext::RegisterSyncBehavior(const uint32_t syncId, Behavior* beha entry.branchContext = branchContext; entry.branchContext.isSync = true; entry.ignoreInterrupts = ignoreInterrupts; + // Add 10 seconds + duration time to account for lag and give clients time to send their syncs to the server. + constexpr float lagTime = 10.0f; + entry.time = lagTime + duration; this->syncEntries.push_back(entry); } @@ -183,6 +186,21 @@ void BehaviorContext::SyncCalculation(const uint32_t syncId, const float time, B this->syncEntries.push_back(entry); } +void BehaviorContext::UpdatePlayerSyncs(float deltaTime) { + uint32_t i = 0; + while (i < this->syncEntries.size()) { + auto& entry = this->syncEntries.at(i); + + entry.time -= deltaTime; + + if (entry.time >= 0.0f) { + i++; + continue; + } + this->syncEntries.erase(this->syncEntries.begin() + i); + } +} + void BehaviorContext::InvokeEnd(const uint32_t id) { std::vector entries; @@ -235,7 +253,7 @@ bool BehaviorContext::CalculateUpdate(const float deltaTime) { // Write message RakNet::BitStream message; - PacketUtils::WriteHeader(message, CLIENT, MSG_CLIENT_GAME_MSG); + PacketUtils::WriteHeader(message, eConnectionType::CLIENT, eClientMessageType::GAME_MSG); message.Write(this->originator); echo.Serialize(&message); diff --git a/dGame/dBehaviors/BehaviorContext.h b/dGame/dBehaviors/BehaviorContext.h index dbba4d91..117f328d 100644 --- a/dGame/dBehaviors/BehaviorContext.h +++ b/dGame/dBehaviors/BehaviorContext.h @@ -80,7 +80,9 @@ struct BehaviorContext uint32_t GetUniqueSkillId() const; - void RegisterSyncBehavior(uint32_t syncId, Behavior* behavior, const BehaviorBranchContext& branchContext, bool ignoreInterrupts = false); + void UpdatePlayerSyncs(float deltaTime); + + void RegisterSyncBehavior(uint32_t syncId, Behavior* behavior, const BehaviorBranchContext& branchContext, const float duration, bool ignoreInterrupts = false); void RegisterTimerBehavior(Behavior* behavior, const BehaviorBranchContext& branchContext, LWOOBJID second = LWOOBJID_EMPTY); diff --git a/dGame/dBehaviors/CMakeLists.txt b/dGame/dBehaviors/CMakeLists.txt index 7b331fe0..8a9368b9 100644 --- a/dGame/dBehaviors/CMakeLists.txt +++ b/dGame/dBehaviors/CMakeLists.txt @@ -22,6 +22,7 @@ set(DGAME_DBEHAVIORS_SOURCES "AirMovementBehavior.cpp" "DurationBehavior.cpp" "EmptyBehavior.cpp" "EndBehavior.cpp" + "FallSpeedBehavior.cpp" "ForceMovementBehavior.cpp" "HealBehavior.cpp" "ImaginationBehavior.cpp" diff --git a/dGame/dBehaviors/ChangeOrientationBehavior.cpp b/dGame/dBehaviors/ChangeOrientationBehavior.cpp index a60be62f..36a2e6a8 100644 --- a/dGame/dBehaviors/ChangeOrientationBehavior.cpp +++ b/dGame/dBehaviors/ChangeOrientationBehavior.cpp @@ -2,43 +2,35 @@ #include "BehaviorBranchContext.h" #include "BehaviorContext.h" #include "EntityManager.h" -#include "BaseCombatAIComponent.h" - -void ChangeOrientationBehavior::Handle(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 + Entity* sourceEntity; + if (this->m_orientCaster) sourceEntity = EntityManager::Instance()->GetEntity(context->originator); + else sourceEntity = EntityManager::Instance()->GetEntity(branch.target); + if (!sourceEntity) return; - auto* self = EntityManager::Instance()->GetEntity(context->originator); - auto* other = EntityManager::Instance()->GetEntity(branch.target); + if (this->m_toTarget) { + Entity* destinationEntity; + if (this->m_orientCaster) destinationEntity = EntityManager::Instance()->GetEntity(branch.target); + else destinationEntity = EntityManager::Instance()->GetEntity(context->originator); + if (!destinationEntity) return; - if (self == nullptr || other == nullptr) return; - - const auto source = self->GetPosition(); - const auto destination = self->GetPosition(); - - if (m_OrientCaster) { - auto* baseCombatAIComponent = self->GetComponent(); - - /*if (baseCombatAIComponent != nullptr) - { - baseCombatAIComponent->LookAt(destination); - } - else*/ - { - self->SetRotation(NiQuaternion::LookAt(source, destination)); - } - - EntityManager::Instance()->SerializeEntity(self); - } else { - other->SetRotation(NiQuaternion::LookAt(destination, source)); - - EntityManager::Instance()->SerializeEntity(other); - } + sourceEntity->SetRotation( + NiQuaternion::LookAt(sourceEntity->GetPosition(), destinationEntity->GetPosition()) + ); + } else if (this->m_toAngle){ + auto baseAngle = NiPoint3(0, 0, this->m_angle); + if (this->m_relative) baseAngle += sourceEntity->GetRotation().GetForwardVector(); + sourceEntity->SetRotation(NiQuaternion::FromEulerAngles(baseAngle)); + } else return; + EntityManager::Instance()->SerializeEntity(sourceEntity); + return; } void ChangeOrientationBehavior::Load() { - m_OrientCaster = GetBoolean("orient_caster"); - m_ToTarget = GetBoolean("to_target"); + this->m_orientCaster = GetBoolean("orient_caster", true); + this->m_toTarget = GetBoolean("to_target", false); + this->m_toAngle = GetBoolean("to_angle", false); + this->m_angle = GetFloat("angle", 0.0f); + this->m_relative = GetBoolean("relative", false); } diff --git a/dGame/dBehaviors/ChangeOrientationBehavior.h b/dGame/dBehaviors/ChangeOrientationBehavior.h index eb038ffb..22c92bb8 100644 --- a/dGame/dBehaviors/ChangeOrientationBehavior.h +++ b/dGame/dBehaviors/ChangeOrientationBehavior.h @@ -2,24 +2,15 @@ #include "Behavior.h" -#include - -class ChangeOrientationBehavior final : public Behavior -{ +class ChangeOrientationBehavior final : public Behavior { public: - bool m_OrientCaster; - bool m_ToTarget; - - /* - * Inherited - */ - - explicit ChangeOrientationBehavior(const uint32_t behaviorId) : Behavior(behaviorId) { - } - - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; - + explicit ChangeOrientationBehavior(const uint32_t behaviorId) : Behavior(behaviorId) {} void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; - void Load() override; +private: + bool m_orientCaster; + bool m_toTarget; + bool m_toAngle; + float m_angle; + bool m_relative; }; diff --git a/dGame/dBehaviors/ChargeUpBehavior.cpp b/dGame/dBehaviors/ChargeUpBehavior.cpp index 1b9ba433..4c7c3dac 100644 --- a/dGame/dBehaviors/ChargeUpBehavior.cpp +++ b/dGame/dBehaviors/ChargeUpBehavior.cpp @@ -12,7 +12,7 @@ void ChargeUpBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitSt return; }; - context->RegisterSyncBehavior(handle, this, branch); + context->RegisterSyncBehavior(handle, this, branch, this->m_MaxDuration); } void ChargeUpBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { @@ -24,4 +24,5 @@ void ChargeUpBehavior::Sync(BehaviorContext* context, RakNet::BitStream* bitStre void ChargeUpBehavior::Load() { this->m_action = GetAction("action"); + this->m_MaxDuration = GetFloat("max_duration"); } diff --git a/dGame/dBehaviors/ChargeUpBehavior.h b/dGame/dBehaviors/ChargeUpBehavior.h index d753895e..ceb40f6c 100644 --- a/dGame/dBehaviors/ChargeUpBehavior.h +++ b/dGame/dBehaviors/ChargeUpBehavior.h @@ -4,14 +4,7 @@ class ChargeUpBehavior final : public Behavior { public: - Behavior* m_action; - - /* - * 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; @@ -20,4 +13,7 @@ public: void Sync(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; void Load() override; +private: + Behavior* m_action; + float m_MaxDuration; }; diff --git a/dGame/dBehaviors/FallSpeedBehavior.cpp b/dGame/dBehaviors/FallSpeedBehavior.cpp new file mode 100644 index 00000000..158c87f6 --- /dev/null +++ b/dGame/dBehaviors/FallSpeedBehavior.cpp @@ -0,0 +1,50 @@ +#include "FallSpeedBehavior.h" + +#include "ControllablePhysicsComponent.h" +#include "BehaviorContext.h" +#include "BehaviorBranchContext.h" + + +void FallSpeedBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { + // make sure required parameter has non-default value + if (m_PercentSlowed == 0.0f) return; + auto* target = EntityManager::Instance()->GetEntity(branch.target); + if (!target) return; + + auto* controllablePhysicsComponent = target->GetComponent(); + if (!controllablePhysicsComponent) return; + controllablePhysicsComponent->SetGravityScale(m_PercentSlowed); + EntityManager::Instance()->SerializeEntity(target); + + if (branch.duration > 0.0f) { + context->RegisterTimerBehavior(this, branch); + } else if (branch.start > 0) { + context->RegisterEndBehavior(this, branch); + } +} + +void FallSpeedBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { + Handle(context, bitStream, branch); +} + +void FallSpeedBehavior::Timer(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second) { + End(context, branch, second); +} + +void FallSpeedBehavior::UnCast(BehaviorContext* context, BehaviorBranchContext branch) { + End(context, branch, LWOOBJID_EMPTY); +} + +void FallSpeedBehavior::End(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second) { + auto* target = EntityManager::Instance()->GetEntity(branch.target); + if (!target) return; + + auto* controllablePhysicsComponent = target->GetComponent(); + if (!controllablePhysicsComponent) return; + controllablePhysicsComponent->SetGravityScale(1); + EntityManager::Instance()->SerializeEntity(target); +} + +void FallSpeedBehavior::Load(){ + m_PercentSlowed = GetFloat("percent_slowed"); +} diff --git a/dGame/dBehaviors/FallSpeedBehavior.h b/dGame/dBehaviors/FallSpeedBehavior.h new file mode 100644 index 00000000..01f0143f --- /dev/null +++ b/dGame/dBehaviors/FallSpeedBehavior.h @@ -0,0 +1,18 @@ +#pragma once +#include "Behavior.h" + +class FallSpeedBehavior final : public Behavior +{ +public: + explicit FallSpeedBehavior(const uint32_t behaviorId) : Behavior(behaviorId) {} + + void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Timer(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second) override; + void End(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second) override; + void UnCast(BehaviorContext* context, BehaviorBranchContext branch) override; + void Load() override; + +private: + float m_PercentSlowed; +}; diff --git a/dGame/dBehaviors/ForceMovementBehavior.cpp b/dGame/dBehaviors/ForceMovementBehavior.cpp index e095447c..52359cf7 100644 --- a/dGame/dBehaviors/ForceMovementBehavior.cpp +++ b/dGame/dBehaviors/ForceMovementBehavior.cpp @@ -16,7 +16,7 @@ void ForceMovementBehavior::Handle(BehaviorContext* context, RakNet::BitStream* Game::logger->Log("ForceMovementBehavior", "Unable to read handle from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); return; } - context->RegisterSyncBehavior(handle, this, branch); + context->RegisterSyncBehavior(handle, this, branch, this->m_Duration); } void ForceMovementBehavior::Sync(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { diff --git a/dGame/dBehaviors/ImmunityBehavior.cpp b/dGame/dBehaviors/ImmunityBehavior.cpp index f4a41c52..a5dd4c85 100644 --- a/dGame/dBehaviors/ImmunityBehavior.cpp +++ b/dGame/dBehaviors/ImmunityBehavior.cpp @@ -7,6 +7,7 @@ #include "dLogger.h" #include "DestroyableComponent.h" #include "ControllablePhysicsComponent.h" +#include "eStateChangeType.h" void ImmunityBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) { auto* target = EntityManager::Instance()->GetEntity(branch.target); diff --git a/dGame/dBehaviors/ProjectileAttackBehavior.cpp b/dGame/dBehaviors/ProjectileAttackBehavior.cpp index 3ce6c415..f65421cb 100644 --- a/dGame/dBehaviors/ProjectileAttackBehavior.cpp +++ b/dGame/dBehaviors/ProjectileAttackBehavior.cpp @@ -6,6 +6,7 @@ #include "dLogger.h" #include "SkillComponent.h" #include "../dWorldServer/ObjectIDManager.h" +#include "eObjectBits.h" void ProjectileAttackBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { LWOOBJID target{}; @@ -107,7 +108,7 @@ void ProjectileAttackBehavior::Calculate(BehaviorContext* context, RakNet::BitSt for (auto i = 0u; i < this->m_projectileCount; ++i) { auto id = static_cast(ObjectIDManager::Instance()->GenerateObjectID()); - id = GeneralUtils::SetBit(id, OBJECT_BIT_SPAWNED); + GeneralUtils::SetBit(id, eObjectBits::SPAWNED); bitStream->Write(id); diff --git a/dGame/dBehaviors/SwitchBehavior.cpp b/dGame/dBehaviors/SwitchBehavior.cpp index c010f31b..bd261906 100644 --- a/dGame/dBehaviors/SwitchBehavior.cpp +++ b/dGame/dBehaviors/SwitchBehavior.cpp @@ -30,7 +30,7 @@ void SwitchBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStre Game::logger->LogDebug("SwitchBehavior", "[%i] State: (%d), imagination: (%i) / (%f)", entity->GetLOT(), state, destroyableComponent->GetImagination(), destroyableComponent->GetMaxImagination()); - if (state || (entity->GetLOT() == 8092 && destroyableComponent->GetImagination() >= m_imagination)) { + if (state) { this->m_actionTrue->Handle(context, bitStream, branch); } else { this->m_actionFalse->Handle(context, bitStream, branch); diff --git a/dGame/dBehaviors/SwitchMultipleBehavior.cpp b/dGame/dBehaviors/SwitchMultipleBehavior.cpp index 078464bb..23411429 100644 --- a/dGame/dBehaviors/SwitchMultipleBehavior.cpp +++ b/dGame/dBehaviors/SwitchMultipleBehavior.cpp @@ -22,13 +22,9 @@ void SwitchMultipleBehavior::Handle(BehaviorContext* context, RakNet::BitStream* for (unsigned int i = 0; i < this->m_behaviors.size(); i++) { const double data = this->m_behaviors.at(i).first; + trigger = i; - if (value <= data) { - - trigger = i; - - break; - } + if (value <= data) break; } auto* behavior = this->m_behaviors.at(trigger).second; diff --git a/dGame/dComponents/BaseCombatAIComponent.cpp b/dGame/dComponents/BaseCombatAIComponent.cpp index 64c739f5..cccaad23 100644 --- a/dGame/dComponents/BaseCombatAIComponent.cpp +++ b/dGame/dComponents/BaseCombatAIComponent.cpp @@ -248,7 +248,7 @@ void BaseCombatAIComponent::CalculateCombat(const float deltaTime) { if (rebuild != nullptr) { const auto state = rebuild->GetState(); - if (state != REBUILD_COMPLETED) { + if (state != eRebuildState::COMPLETED) { return; } } @@ -566,7 +566,7 @@ bool BaseCombatAIComponent::IsEnemy(LWOOBJID target) const { if (quickbuild != nullptr) { const auto state = quickbuild->GetState(); - if (state != REBUILD_COMPLETED) { + if (state != eRebuildState::COMPLETED) { return false; } } diff --git a/dGame/dComponents/CharacterComponent.cpp b/dGame/dComponents/CharacterComponent.cpp index 6394cc32..32fe564c 100644 --- a/dGame/dComponents/CharacterComponent.cpp +++ b/dGame/dComponents/CharacterComponent.cpp @@ -13,8 +13,9 @@ #include "VehiclePhysicsComponent.h" #include "GameMessages.h" #include "Item.h" -#include "AMFFormat.h" +#include "Amf3.h" #include "eGameMasterLevel.h" +#include "eGameActivity.h" CharacterComponent::CharacterComponent(Entity* parent, Character* character) : Component(parent) { m_Character = character; @@ -35,7 +36,7 @@ CharacterComponent::CharacterComponent(Entity* parent, Character* character) : C m_EditorLevel = m_GMLevel; m_Reputation = 0; - m_CurrentActivity = 0; + m_CurrentActivity = eGameActivity::NONE; m_CountryCode = 0; m_LastUpdateTimestamp = std::time(nullptr); } @@ -733,6 +734,6 @@ void CharacterComponent::RemoveVentureVisionEffect(std::string ventureVisionType void CharacterComponent::UpdateClientMinimap(bool showFaction, std::string ventureVisionType) const { if (!m_Parent) return; AMFArrayValue arrayToSend; - arrayToSend.InsertValue(ventureVisionType, showFaction ? static_cast(new AMFTrueValue()) : static_cast(new AMFFalseValue())); - GameMessages::SendUIMessageServerToSingleClient(m_Parent, m_Parent ? m_Parent->GetSystemAddress() : UNASSIGNED_SYSTEM_ADDRESS, "SetFactionVisibility", &arrayToSend); + arrayToSend.Insert(ventureVisionType, showFaction); + GameMessages::SendUIMessageServerToSingleClient(m_Parent, m_Parent ? m_Parent->GetSystemAddress() : UNASSIGNED_SYSTEM_ADDRESS, "SetFactionVisibility", arrayToSend); } diff --git a/dGame/dComponents/CharacterComponent.h b/dGame/dComponents/CharacterComponent.h index 0e047494..e5ca6da5 100644 --- a/dGame/dComponents/CharacterComponent.h +++ b/dGame/dComponents/CharacterComponent.h @@ -11,6 +11,8 @@ #include "tinyxml2.h" #include "eReplicaComponentType.h" +enum class eGameActivity : uint32_t; + /** * The statistics that can be achieved per zone */ @@ -112,13 +114,13 @@ public: * Gets the current activity that the character is partaking in, see ScriptedActivityComponent for more details * @return the current activity that the character is partaking in */ - const uint32_t GetCurrentActivity() const { return m_CurrentActivity; } + const eGameActivity GetCurrentActivity() const { return m_CurrentActivity; } /** * Set the current activity of the character, see ScriptedActivityComponent for more details * @param currentActivity the activity to set */ - void SetCurrentActivity(uint32_t currentActivity) { m_CurrentActivity = currentActivity; m_DirtyCurrentActivity = true; } + void SetCurrentActivity(eGameActivity currentActivity) { m_CurrentActivity = currentActivity; m_DirtyCurrentActivity = true; } /** * Gets if the entity is currently racing @@ -353,7 +355,7 @@ private: /** * The ID of the curently active activity */ - int m_CurrentActivity; + eGameActivity m_CurrentActivity; /** * Whether the social info has been changed diff --git a/dGame/dComponents/ControllablePhysicsComponent.cpp b/dGame/dComponents/ControllablePhysicsComponent.cpp index 6a6d69ce..d1b44200 100644 --- a/dGame/dComponents/ControllablePhysicsComponent.cpp +++ b/dGame/dComponents/ControllablePhysicsComponent.cpp @@ -13,6 +13,7 @@ #include "Character.h" #include "dZoneManager.h" #include "LevelProgressionComponent.h" +#include "eStateChangeType.h" ControllablePhysicsComponent::ControllablePhysicsComponent(Entity* entity) : Component(entity) { m_Position = {}; @@ -319,7 +320,7 @@ void ControllablePhysicsComponent::RemoveSpeedboost(float value) { // Recalculate speedboost since we removed one m_SpeedBoost = 0.0f; - if (m_ActiveSpeedBoosts.size() == 0) { // no active speed boosts left, so return to base speed + if (m_ActiveSpeedBoosts.empty()) { // no active speed boosts left, so return to base speed auto* levelProgressionComponent = m_Parent->GetComponent(); if (levelProgressionComponent) m_SpeedBoost = levelProgressionComponent->GetSpeedBase(); } else { // Used the last applied speedboost diff --git a/dGame/dComponents/ControllablePhysicsComponent.h b/dGame/dComponents/ControllablePhysicsComponent.h index a7359a26..470a7af4 100644 --- a/dGame/dComponents/ControllablePhysicsComponent.h +++ b/dGame/dComponents/ControllablePhysicsComponent.h @@ -14,6 +14,7 @@ class Entity; class dpEntity; +enum class eStateChangeType : uint32_t; /** * Handles the movement of controllable Entities, e.g. enemies and players @@ -275,7 +276,7 @@ public: * The speed boosts of this component. * @return All active Speed boosts for this component. */ - std::vector GetActiveSpeedboosts() { return m_ActivePickupRadiusScales; }; + std::vector GetActiveSpeedboosts() { return m_ActiveSpeedBoosts; }; /** * Activates the Bubble Buff diff --git a/dGame/dComponents/DestroyableComponent.cpp b/dGame/dComponents/DestroyableComponent.cpp index c2d72941..01ebf5c1 100644 --- a/dGame/dComponents/DestroyableComponent.cpp +++ b/dGame/dComponents/DestroyableComponent.cpp @@ -4,8 +4,8 @@ #include "Game.h" #include "dConfig.h" -#include "AMFFormat.h" -#include "AMFFormat_BitStream.h" +#include "Amf3.h" +#include "AmfSerialize.h" #include "GameMessages.h" #include "User.h" #include "CDClientManager.h" @@ -33,6 +33,8 @@ #include "dZoneManager.h" #include "WorldConfig.h" #include "eMissionTaskType.h" +#include "eStateChangeType.h" +#include "eGameActivity.h" #include "CDComponentsRegistryTable.h" @@ -243,16 +245,12 @@ void DestroyableComponent::SetMaxHealth(float value, bool playAnim) { if (playAnim) { // Now update the player bar if (!m_Parent->GetParentUser()) return; - AMFStringValue* amount = new AMFStringValue(); - amount->SetStringValue(std::to_string(difference)); - AMFStringValue* type = new AMFStringValue(); - type->SetStringValue("health"); AMFArrayValue args; - args.InsertValue("amount", amount); - args.InsertValue("type", type); + args.Insert("amount", std::to_string(difference)); + args.Insert("type", "health"); - GameMessages::SendUIMessageServerToSingleClient(m_Parent, m_Parent->GetParentUser()->GetSystemAddress(), "MaxPlayerBarUpdate", &args); + GameMessages::SendUIMessageServerToSingleClient(m_Parent, m_Parent->GetParentUser()->GetSystemAddress(), "MaxPlayerBarUpdate", args); } EntityManager::Instance()->SerializeEntity(m_Parent); @@ -288,16 +286,12 @@ void DestroyableComponent::SetMaxArmor(float value, bool playAnim) { if (playAnim) { // Now update the player bar if (!m_Parent->GetParentUser()) return; - AMFStringValue* amount = new AMFStringValue(); - amount->SetStringValue(std::to_string(value)); - AMFStringValue* type = new AMFStringValue(); - type->SetStringValue("armor"); AMFArrayValue args; - args.InsertValue("amount", amount); - args.InsertValue("type", type); + args.Insert("amount", std::to_string(value)); + args.Insert("type", "armor"); - GameMessages::SendUIMessageServerToSingleClient(m_Parent, m_Parent->GetParentUser()->GetSystemAddress(), "MaxPlayerBarUpdate", &args); + GameMessages::SendUIMessageServerToSingleClient(m_Parent, m_Parent->GetParentUser()->GetSystemAddress(), "MaxPlayerBarUpdate", args); } EntityManager::Instance()->SerializeEntity(m_Parent); @@ -332,16 +326,12 @@ void DestroyableComponent::SetMaxImagination(float value, bool playAnim) { if (playAnim) { // Now update the player bar if (!m_Parent->GetParentUser()) return; - AMFStringValue* amount = new AMFStringValue(); - amount->SetStringValue(std::to_string(difference)); - AMFStringValue* type = new AMFStringValue(); - type->SetStringValue("imagination"); AMFArrayValue args; - args.InsertValue("amount", amount); - args.InsertValue("type", type); + args.Insert("amount", std::to_string(difference)); + args.Insert("type", "imagination"); - GameMessages::SendUIMessageServerToSingleClient(m_Parent, m_Parent->GetParentUser()->GetSystemAddress(), "MaxPlayerBarUpdate", &args); + GameMessages::SendUIMessageServerToSingleClient(m_Parent, m_Parent->GetParentUser()->GetSystemAddress(), "MaxPlayerBarUpdate", args); } EntityManager::Instance()->SerializeEntity(m_Parent); } @@ -468,7 +458,7 @@ bool DestroyableComponent::IsKnockbackImmune() const { auto* characterComponent = m_Parent->GetComponent(); auto* inventoryComponent = m_Parent->GetComponent(); - if (characterComponent != nullptr && inventoryComponent != nullptr && characterComponent->GetCurrentActivity() == eGameActivities::ACTIVITY_QUICKBUILDING) { + if (characterComponent != nullptr && inventoryComponent != nullptr && characterComponent->GetCurrentActivity() == eGameActivity::QUICKBUILDING) { const auto hasPassive = inventoryComponent->HasAnyPassive({ eItemSetPassiveAbilityID::EngineerRank2, eItemSetPassiveAbilityID::EngineerRank3, eItemSetPassiveAbilityID::SummonerRank2, eItemSetPassiveAbilityID::SummonerRank3, @@ -514,7 +504,7 @@ bool DestroyableComponent::CheckValidity(const LWOOBJID target, const bool ignor if (targetQuickbuild != nullptr) { const auto state = targetQuickbuild->GetState(); - if (state != REBUILD_COMPLETED) { + if (state != eRebuildState::COMPLETED) { return false; } } @@ -803,7 +793,7 @@ void DestroyableComponent::Smash(const LWOOBJID source, const eKillType killType coinsTotal -= coinsToLose; LootGenerator::Instance().DropLoot(m_Parent, m_Parent, -1, coinsToLose, coinsToLose); - character->SetCoins(coinsTotal, eLootSourceType::LOOT_SOURCE_PICKUP); + character->SetCoins(coinsTotal, eLootSourceType::PICKUP); } } @@ -992,7 +982,7 @@ void DestroyableComponent::DoHardcoreModeDrops(const LWOOBJID source){ auto uscoreToLose = uscore * (EntityManager::Instance()->GetHardcoreLoseUscoreOnDeathPercent() / 100); character->SetUScore(uscore - uscoreToLose); - GameMessages::SendModifyLEGOScore(m_Parent, m_Parent->GetSystemAddress(), -uscoreToLose, eLootSourceType::LOOT_SOURCE_MISSION); + GameMessages::SendModifyLEGOScore(m_Parent, m_Parent->GetSystemAddress(), -uscoreToLose, eLootSourceType::MISSION); if (EntityManager::Instance()->GetHardcoreDropinventoryOnDeath()) { //drop all items from inventory: @@ -1023,7 +1013,7 @@ void DestroyableComponent::DoHardcoreModeDrops(const LWOOBJID source){ auto coins = chars->GetCoins(); //lose all coins: - chars->SetCoins(0, eLootSourceType::LOOT_SOURCE_NONE); + chars->SetCoins(0, eLootSourceType::NONE); //drop all coins: GameMessages::SendDropClientLoot(m_Parent, source, LOT_NULL, coins, m_Parent->GetPosition()); @@ -1047,7 +1037,7 @@ void DestroyableComponent::DoHardcoreModeDrops(const LWOOBJID source){ int uscore = maxHealth * EntityManager::Instance()->GetHardcoreUscoreEnemiesMultiplier(); playerStats->SetUScore(playerStats->GetUScore() + uscore); - GameMessages::SendModifyLEGOScore(player, player->GetSystemAddress(), uscore, eLootSourceType::LOOT_SOURCE_MISSION); + GameMessages::SendModifyLEGOScore(player, player->GetSystemAddress(), uscore, eLootSourceType::MISSION); EntityManager::Instance()->SerializeEntity(m_Parent); } diff --git a/dGame/dComponents/DestroyableComponent.h b/dGame/dComponents/DestroyableComponent.h index 47be96a0..66c8374d 100644 --- a/dGame/dComponents/DestroyableComponent.h +++ b/dGame/dComponents/DestroyableComponent.h @@ -11,6 +11,7 @@ namespace CppScripts { class Script; }; //! namespace CppScripts +enum class eStateChangeType : uint32_t; /** * Represents the stats of an entity, for example its health, imagination and armor. Also handles factions, which diff --git a/dGame/dComponents/InventoryComponent.cpp b/dGame/dComponents/InventoryComponent.cpp index dc8fdbdc..907356ce 100644 --- a/dGame/dComponents/InventoryComponent.cpp +++ b/dGame/dComponents/InventoryComponent.cpp @@ -29,6 +29,8 @@ #include "eUnequippableActiveType.h" #include "CppScripts.h" #include "eMissionTaskType.h" +#include "eStateChangeType.h" +#include "eUseItemResponse.h" #include "CDComponentsRegistryTable.h" #include "CDInventoryComponentTable.h" @@ -356,7 +358,7 @@ void InventoryComponent::MoveItemToInventory(Item* item, const eInventoryType in left -= delta; - AddItem(lot, delta, eLootSourceType::LOOT_SOURCE_NONE, inventory, {}, LWOOBJID_EMPTY, showFlyingLot, isModMoveAndEquip, LWOOBJID_EMPTY, origin->GetType(), 0, false, preferredSlot); + AddItem(lot, delta, eLootSourceType::NONE, inventory, {}, LWOOBJID_EMPTY, showFlyingLot, isModMoveAndEquip, LWOOBJID_EMPTY, origin->GetType(), 0, false, preferredSlot); item->SetCount(item->GetCount() - delta, false, false); @@ -371,7 +373,7 @@ void InventoryComponent::MoveItemToInventory(Item* item, const eInventoryType in const auto delta = std::min(item->GetCount(), count); - AddItem(lot, delta, eLootSourceType::LOOT_SOURCE_NONE, inventory, config, LWOOBJID_EMPTY, showFlyingLot, isModMoveAndEquip, subkey, origin->GetType(), 0, item->GetBound(), preferredSlot); + AddItem(lot, delta, eLootSourceType::NONE, inventory, config, LWOOBJID_EMPTY, showFlyingLot, isModMoveAndEquip, subkey, origin->GetType(), 0, item->GetBound(), preferredSlot); item->SetCount(item->GetCount() - delta, false, false); } @@ -1247,7 +1249,7 @@ void InventoryComponent::SpawnPet(Item* item) { auto destroyableComponent = m_Parent->GetComponent(); if (Game::config->GetValue("pets_take_imagination") == "1" && destroyableComponent && destroyableComponent->GetImagination() <= 0) { - GameMessages::SendUseItemRequirementsResponse(m_Parent->GetObjectID(), m_Parent->GetSystemAddress(), UseItemResponse::NoImaginationForPet); + GameMessages::SendUseItemRequirementsResponse(m_Parent->GetObjectID(), m_Parent->GetSystemAddress(), eUseItemResponse::NoImaginationForPet); return; } diff --git a/dGame/dComponents/InventoryComponent.h b/dGame/dComponents/InventoryComponent.h index d695737c..801f9f51 100644 --- a/dGame/dComponents/InventoryComponent.h +++ b/dGame/dComponents/InventoryComponent.h @@ -21,6 +21,7 @@ #include "PossessorComponent.h" #include "eInventoryType.h" #include "eReplicaComponentType.h" +#include "eLootSourceType.h" class Entity; class ItemSet; @@ -99,7 +100,7 @@ public: void AddItem( LOT lot, uint32_t count, - eLootSourceType lootSourceType = eLootSourceType::LOOT_SOURCE_NONE, + eLootSourceType lootSourceType = eLootSourceType::NONE, eInventoryType inventoryType = INVALID, const std::vector& config = {}, LWOOBJID parent = LWOOBJID_EMPTY, diff --git a/dGame/dComponents/LevelProgressionComponent.cpp b/dGame/dComponents/LevelProgressionComponent.cpp index 814a7a86..8163e736 100644 --- a/dGame/dComponents/LevelProgressionComponent.cpp +++ b/dGame/dComponents/LevelProgressionComponent.cpp @@ -59,7 +59,7 @@ void LevelProgressionComponent::HandleLevelUp() { for (auto* reward : rewards) { switch (reward->rewardType) { case 0: - inventoryComponent->AddItem(reward->value, reward->count, eLootSourceType::LOOT_SOURCE_LEVEL_REWARD); + inventoryComponent->AddItem(reward->value, reward->count, eLootSourceType::LEVEL_REWARD); break; case 4: { diff --git a/dGame/dComponents/MissionComponent.cpp b/dGame/dComponents/MissionComponent.cpp index 0ae0f07e..8f61c1aa 100644 --- a/dGame/dComponents/MissionComponent.cpp +++ b/dGame/dComponents/MissionComponent.cpp @@ -13,7 +13,7 @@ #include "InventoryComponent.h" #include "GameMessages.h" #include "Game.h" -#include "AMFFormat.h" +#include "Amf3.h" #include "dZoneManager.h" #include "Mail.h" #include "MissionPrerequisites.h" diff --git a/dGame/dComponents/ModuleAssemblyComponent.h b/dGame/dComponents/ModuleAssemblyComponent.h index c6e217ed..39670c9a 100644 --- a/dGame/dComponents/ModuleAssemblyComponent.h +++ b/dGame/dComponents/ModuleAssemblyComponent.h @@ -14,7 +14,7 @@ class ModuleAssemblyComponent : public Component { public: static const eReplicaComponentType ComponentType = eReplicaComponentType::MODULE_ASSEMBLY; - ModuleAssemblyComponent(Entity* MSG_CHAT_INTERNAL_PLAYER_REMOVED_NOTIFICATION); + ModuleAssemblyComponent(Entity* parent); ~ModuleAssemblyComponent() override; void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); diff --git a/dGame/dComponents/MovementAIComponent.cpp b/dGame/dComponents/MovementAIComponent.cpp index 278e9106..7acec5f7 100644 --- a/dGame/dComponents/MovementAIComponent.cpp +++ b/dGame/dComponents/MovementAIComponent.cpp @@ -307,13 +307,14 @@ float MovementAIComponent::GetBaseSpeed(LOT lot) { foundComponent: - float speed; + // Client defaults speed to 10 and if the speed is also null in the table, it defaults to 10. + float speed = 10.0f; - if (physicsComponent == nullptr) { - speed = 8; - } else { - speed = physicsComponent->speed; - } + if (physicsComponent) speed = physicsComponent->speed; + + float delta = fabs(speed) - 1.0f; + + if (delta <= std::numeric_limits::epsilon()) speed = 10.0f; m_PhysicsSpeedCache[lot] = speed; diff --git a/dGame/dComponents/PetComponent.cpp b/dGame/dComponents/PetComponent.cpp index db4d5693..c37ce6a0 100644 --- a/dGame/dComponents/PetComponent.cpp +++ b/dGame/dComponents/PetComponent.cpp @@ -15,6 +15,10 @@ #include "PetDigServer.h" #include "../dWorldServer/ObjectIDManager.h" #include "eUnequippableActiveType.h" +#include "eTerminateType.h" +#include "ePetTamingNotifyType.h" +#include "eUseItemResponse.h" +#include "ePlayerFlag.h" #include "Game.h" #include "dConfig.h" @@ -23,6 +27,7 @@ #include "EntityInfo.h" #include "eMissionTaskType.h" #include "RenderComponent.h" +#include "eObjectBits.h" #include "eGameMasterLevel.h" std::unordered_map PetComponent::buildCache{}; @@ -33,7 +38,7 @@ std::unordered_map PetComponent::activePets{}; * Maps all the pet lots to a flag indicating that the player has caught it. All basic pets have been guessed by ObjID * while the faction ones could be checked using their respective missions. */ -std::map PetComponent::petFlags = { +std::map PetComponent::petFlags = { { 3050, 801 }, // Elephant { 3054, 803 }, // Cat { 3195, 806 }, // Triceratops @@ -285,7 +290,7 @@ void PetComponent::OnUse(Entity* originator) { m_Parent->GetObjectID(), LWOOBJID_EMPTY, true, - NOTIFY_TYPE_BEGIN, + ePetTamingNotifyType::BEGIN, petPosition, position, rotation, @@ -297,7 +302,7 @@ void PetComponent::OnUse(Entity* originator) { LWOOBJID_EMPTY, originator->GetObjectID(), true, - NOTIFY_TYPE_BEGIN, + ePetTamingNotifyType::BEGIN, petPosition, position, rotation, @@ -313,7 +318,7 @@ void PetComponent::OnUse(Entity* originator) { // Notify the start of a pet taming minigame for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_Parent)) { - script->OnNotifyPetTamingMinigame(m_Parent, originator, NOTIFY_TYPE_BEGIN); + script->OnNotifyPetTamingMinigame(m_Parent, originator, ePetTamingNotifyType::BEGIN); } } @@ -552,8 +557,8 @@ void PetComponent::NotifyTamingBuildSuccess(NiPoint3 position) { LWOOBJID petSubKey = ObjectIDManager::Instance()->GenerateRandomObjectID(); - petSubKey = GeneralUtils::SetBit(petSubKey, OBJECT_BIT_CHARACTER); - petSubKey = GeneralUtils::SetBit(petSubKey, OBJECT_BIT_PERSISTENT); + GeneralUtils::SetBit(petSubKey, eObjectBits::CHARACTER); + GeneralUtils::SetBit(petSubKey, eObjectBits::PERSISTENT); m_DatabaseId = petSubKey; @@ -566,7 +571,7 @@ void PetComponent::NotifyTamingBuildSuccess(NiPoint3 position) { GameMessages::SendRegisterPetDBID(m_Tamer, petSubKey, tamer->GetSystemAddress()); - inventoryComponent->AddItem(m_Parent->GetLOT(), 1, eLootSourceType::LOOT_SOURCE_ACTIVITY, eInventoryType::MODELS, {}, LWOOBJID_EMPTY, true, false, petSubKey); + inventoryComponent->AddItem(m_Parent->GetLOT(), 1, eLootSourceType::ACTIVITY, eInventoryType::MODELS, {}, LWOOBJID_EMPTY, true, false, petSubKey); auto* item = inventoryComponent->FindItemBySubKey(petSubKey, MODELS); if (item == nullptr) { @@ -590,7 +595,7 @@ void PetComponent::NotifyTamingBuildSuccess(NiPoint3 position) { LWOOBJID_EMPTY, LWOOBJID_EMPTY, false, - NOTIFY_TYPE_NAMINGPET, + ePetTamingNotifyType::NAMINGPET, NiPoint3::ZERO, NiPoint3::ZERO, NiQuaternion::IDENTITY, @@ -670,7 +675,7 @@ void PetComponent::RequestSetPetName(std::u16string name) { m_Parent->GetObjectID(), m_Tamer, false, - NOTIFY_TYPE_SUCCESS, + ePetTamingNotifyType::SUCCESS, NiPoint3::ZERO, NiPoint3::ZERO, NiQuaternion::IDENTITY, @@ -691,7 +696,7 @@ void PetComponent::RequestSetPetName(std::u16string name) { // Notify the end of a pet taming minigame for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_Parent)) { - script->OnNotifyPetTamingMinigame(m_Parent, tamer, NOTIFY_TYPE_SUCCESS); + script->OnNotifyPetTamingMinigame(m_Parent, tamer, ePetTamingNotifyType::SUCCESS); } } @@ -711,7 +716,7 @@ void PetComponent::ClientExitTamingMinigame(bool voluntaryExit) { m_Parent->GetObjectID(), m_Tamer, false, - NOTIFY_TYPE_QUIT, + ePetTamingNotifyType::QUIT, NiPoint3::ZERO, NiPoint3::ZERO, NiQuaternion::IDENTITY, @@ -732,7 +737,7 @@ void PetComponent::ClientExitTamingMinigame(bool voluntaryExit) { // Notify the end of a pet taming minigame for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_Parent)) { - script->OnNotifyPetTamingMinigame(m_Parent, tamer, NOTIFY_TYPE_QUIT); + script->OnNotifyPetTamingMinigame(m_Parent, tamer, ePetTamingNotifyType::QUIT); } } @@ -762,7 +767,7 @@ void PetComponent::ClientFailTamingMinigame() { m_Parent->GetObjectID(), m_Tamer, false, - NOTIFY_TYPE_FAILED, + ePetTamingNotifyType::FAILED, NiPoint3::ZERO, NiPoint3::ZERO, NiQuaternion::IDENTITY, @@ -783,7 +788,7 @@ void PetComponent::ClientFailTamingMinigame() { // Notify the end of a pet taming minigame for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_Parent)) { - script->OnNotifyPetTamingMinigame(m_Parent, tamer, NOTIFY_TYPE_FAILED); + script->OnNotifyPetTamingMinigame(m_Parent, tamer, ePetTamingNotifyType::FAILED); } } @@ -884,7 +889,7 @@ void PetComponent::Activate(Item* item, bool registerPet, bool fromTaming) { EntityManager::Instance()->SerializeEntity(m_Parent); - owner->GetCharacter()->SetPlayerFlag(69, true); + owner->GetCharacter()->SetPlayerFlag(ePlayerFlag::FIRST_MANUAL_PET_HIBERNATE, true); if (registerPet) { GameMessages::SendAddPetToPlayer(m_Owner, 0, GeneralUtils::UTF8ToUTF16(m_Name), m_DatabaseId, m_Parent->GetLOT(), owner->GetSystemAddress()); @@ -928,7 +933,7 @@ void PetComponent::AddDrainImaginationTimer(Item* item, bool fromTaming) { auto playerEntity = playerDestroyableComponent->GetParent(); if (!playerEntity) return; - GameMessages::SendUseItemRequirementsResponse(playerEntity->GetObjectID(), playerEntity->GetSystemAddress(), UseItemResponse::NoImaginationForPet); + GameMessages::SendUseItemRequirementsResponse(playerEntity->GetObjectID(), playerEntity->GetSystemAddress(), eUseItemResponse::NoImaginationForPet); } this->AddDrainImaginationTimer(item); diff --git a/dGame/dComponents/PetComponent.h b/dGame/dComponents/PetComponent.h index e3c1556b..b3d089a9 100644 --- a/dGame/dComponents/PetComponent.h +++ b/dGame/dComponents/PetComponent.h @@ -263,7 +263,7 @@ private: /** * Flags that indicate that a player has tamed a pet, indexed by the LOT of the pet */ - static std::map petFlags; + static std::map petFlags; /** * The ID of the component in the pet component table diff --git a/dGame/dComponents/PhantomPhysicsComponent.cpp b/dGame/dComponents/PhantomPhysicsComponent.cpp index ce205826..e6272aa4 100644 --- a/dGame/dComponents/PhantomPhysicsComponent.cpp +++ b/dGame/dComponents/PhantomPhysicsComponent.cpp @@ -216,6 +216,13 @@ PhantomPhysicsComponent::PhantomPhysicsComponent(Entity* parent) : Component(par m_dpEntity->SetRotation(m_Rotation); m_dpEntity->SetPosition(m_Position); dpWorld::Instance().AddEntity(m_dpEntity); + } else if (info->physicsAsset == "env\\env_won_fv_gas-blocking-volume.hkx"){ + m_dpEntity = new dpEntity(m_Parent->GetObjectID(), 390.496826f, 111.467964f, 600.821534f, true); + m_dpEntity->SetScale(m_Scale); + m_dpEntity->SetRotation(m_Rotation); + m_Position.y -= (111.467964f * m_Scale) / 2; + m_dpEntity->SetPosition(m_Position); + dpWorld::Instance().AddEntity(m_dpEntity); } else { //Game::logger->Log("PhantomPhysicsComponent", "This one is supposed to have %s", info->physicsAsset.c_str()); diff --git a/dGame/dComponents/PossessorComponent.cpp b/dGame/dComponents/PossessorComponent.cpp index 69046c3b..387b3479 100644 --- a/dGame/dComponents/PossessorComponent.cpp +++ b/dGame/dComponents/PossessorComponent.cpp @@ -4,6 +4,8 @@ #include "EntityManager.h" #include "GameMessages.h" #include "eUnequippableActiveType.h" +#include "eControlScheme.h" +#include "eStateChangeType.h" PossessorComponent::PossessorComponent(Entity* parent) : Component(parent) { m_Possessable = LWOOBJID_EMPTY; @@ -78,5 +80,5 @@ void PossessorComponent::Dismount(Entity* mount, bool forceDismount) { if (characterComponent) characterComponent->SetIsRacing(false); } // Make sure we don't have wacky controls - GameMessages::SendSetPlayerControlScheme(m_Parent, eControlSceme::SCHEME_A); + GameMessages::SendSetPlayerControlScheme(m_Parent, eControlScheme::SCHEME_A); } diff --git a/dGame/dComponents/PropertyEntranceComponent.cpp b/dGame/dComponents/PropertyEntranceComponent.cpp index c251dc96..bff917d8 100644 --- a/dGame/dComponents/PropertyEntranceComponent.cpp +++ b/dGame/dComponents/PropertyEntranceComponent.cpp @@ -11,7 +11,8 @@ #include "CharacterComponent.h" #include "UserManager.h" #include "dLogger.h" -#include "AMFFormat.h" +#include "Amf3.h" +#include "eObjectBits.h" #include "eGameMasterLevel.h" PropertyEntranceComponent::PropertyEntranceComponent(uint32_t componentID, Entity* parent) : Component(parent) { @@ -35,12 +36,9 @@ void PropertyEntranceComponent::OnUse(Entity* entity) { AMFArrayValue args; - auto* state = new AMFStringValue(); - state->SetStringValue("property_menu"); + args.Insert("state", "property_menu"); - args.InsertValue("state", state); - - GameMessages::SendUIMessageServerToSingleClient(entity, entity->GetSystemAddress(), "pushGameState", &args); + GameMessages::SendUIMessageServerToSingleClient(entity, entity->GetSystemAddress(), "pushGameState", args); } void PropertyEntranceComponent::OnEnterProperty(Entity* entity, uint32_t index, bool returnToZone, const SystemAddress& sysAddr) { @@ -243,8 +241,8 @@ void PropertyEntranceComponent::OnPropertyEntranceSync(Entity* entity, bool incl // Convert owner char id to LWOOBJID LWOOBJID ownerObjId = owner; - ownerObjId = GeneralUtils::SetBit(ownerObjId, OBJECT_BIT_CHARACTER); - ownerObjId = GeneralUtils::SetBit(ownerObjId, OBJECT_BIT_PERSISTENT); + GeneralUtils::SetBit(ownerObjId, eObjectBits::CHARACTER); + GeneralUtils::SetBit(ownerObjId, eObjectBits::PERSISTENT); // Query to get friend and best friend fields auto friendCheck = Database::CreatePreppedStmt("SELECT best_friend FROM friends WHERE (player_id = ? AND friend_id = ?) OR (player_id = ? AND friend_id = ?)"); diff --git a/dGame/dComponents/PropertyManagementComponent.cpp b/dGame/dComponents/PropertyManagementComponent.cpp index 0b05b10e..c87d0744 100644 --- a/dGame/dComponents/PropertyManagementComponent.cpp +++ b/dGame/dComponents/PropertyManagementComponent.cpp @@ -19,6 +19,7 @@ #include "PropertyEntranceComponent.h" #include "InventoryComponent.h" #include "eMissionTaskType.h" +#include "eObjectBits.h" #include #include "CppScripts.h" @@ -66,8 +67,8 @@ PropertyManagementComponent::PropertyManagementComponent(Entity* parent) : Compo if (propertyEntry->next()) { this->propertyId = propertyEntry->getUInt64(1); this->owner = propertyEntry->getUInt64(2); - this->owner = GeneralUtils::SetBit(this->owner, OBJECT_BIT_CHARACTER); - this->owner = GeneralUtils::SetBit(this->owner, OBJECT_BIT_PERSISTENT); + GeneralUtils::SetBit(this->owner, eObjectBits::CHARACTER); + GeneralUtils::SetBit(this->owner, eObjectBits::PERSISTENT); this->clone_Id = propertyEntry->getInt(2); this->propertyName = propertyEntry->getString(5).c_str(); this->propertyDescription = propertyEntry->getString(6).c_str(); @@ -372,16 +373,15 @@ void PropertyManagementComponent::UpdateModelPosition(const LWOOBJID id, const N info.emulated = true; info.emulator = EntityManager::Instance()->GetZoneControlEntity()->GetObjectID(); - LWOOBJID id = static_cast(persistentId) | 1ull << OBJECT_BIT_CLIENT; - - info.spawnerID = id; + info.spawnerID = persistentId; + GeneralUtils::SetBit(info.spawnerID, eObjectBits::CLIENT); const auto spawnerId = dZoneManager::Instance()->MakeSpawner(info); auto* spawner = dZoneManager::Instance()->GetSpawner(spawnerId); auto ldfModelBehavior = new LDFData(u"modelBehaviors", 0); - auto userModelID = new LDFData(u"userModelID", id); + auto userModelID = new LDFData(u"userModelID", info.spawnerID); auto modelType = new LDFData(u"modelType", 2); auto propertyObjectID = new LDFData(u"propertyObjectID", true); auto componentWhitelist = new LDFData(u"componentWhitelist", 1); @@ -476,7 +476,7 @@ void PropertyManagementComponent::DeleteModel(const LWOOBJID id, const int delet settings.push_back(propertyObjectID); settings.push_back(modelType); - inventoryComponent->AddItem(6662, 1, eLootSourceType::LOOT_SOURCE_DELETION, eInventoryType::MODELS_IN_BBB, settings, LWOOBJID_EMPTY, false, false, spawnerId); + inventoryComponent->AddItem(6662, 1, eLootSourceType::DELETION, eInventoryType::MODELS_IN_BBB, settings, LWOOBJID_EMPTY, false, false, spawnerId); auto* item = inventoryComponent->FindItemBySubKey(spawnerId); if (item == nullptr) { @@ -498,7 +498,7 @@ void PropertyManagementComponent::DeleteModel(const LWOOBJID id, const int delet if (spawner != nullptr) { dZoneManager::Instance()->RemoveSpawner(spawner->m_Info.spawnerID); } else { - model->Smash(SILENT); + model->Smash(LWOOBJID_EMPTY, eKillType::SILENT); } item->SetCount(0, true, false, false); @@ -506,7 +506,7 @@ void PropertyManagementComponent::DeleteModel(const LWOOBJID id, const int delet return; } - inventoryComponent->AddItem(model->GetLOT(), 1, eLootSourceType::LOOT_SOURCE_DELETION, INVALID, {}, LWOOBJID_EMPTY, false); + inventoryComponent->AddItem(model->GetLOT(), 1, eLootSourceType::DELETION, INVALID, {}, LWOOBJID_EMPTY, false); auto* item = inventoryComponent->FindItemByLot(model->GetLOT()); @@ -551,7 +551,7 @@ void PropertyManagementComponent::DeleteModel(const LWOOBJID id, const int delet if (spawner != nullptr) { dZoneManager::Instance()->RemoveSpawner(spawner->m_Info.spawnerID); } else { - model->Smash(SILENT); + model->Smash(LWOOBJID_EMPTY, eKillType::SILENT); } } @@ -622,8 +622,8 @@ void PropertyManagementComponent::Load() { //BBB property models need to have extra stuff set for them: if (lot == 14) { LWOOBJID blueprintID = lookupResult->getUInt(10); - blueprintID = GeneralUtils::SetBit(blueprintID, OBJECT_BIT_CHARACTER); - blueprintID = GeneralUtils::SetBit(blueprintID, OBJECT_BIT_PERSISTENT); + GeneralUtils::SetBit(blueprintID, eObjectBits::CHARACTER); + GeneralUtils::SetBit(blueprintID, eObjectBits::PERSISTENT); LDFBaseData* ldfBlueprintID = new LDFData(u"blueprintid", blueprintID); LDFBaseData* componentWhitelist = new LDFData(u"componentWhitelist", 1); diff --git a/dGame/dComponents/RacingControlComponent.cpp b/dGame/dComponents/RacingControlComponent.cpp index fe4f1faf..4a4ead59 100644 --- a/dGame/dComponents/RacingControlComponent.cpp +++ b/dGame/dComponents/RacingControlComponent.cpp @@ -23,6 +23,8 @@ #include "dConfig.h" #include "Loot.h" #include "eMissionTaskType.h" +#include "dZoneManager.h" +#include "CDActivitiesTable.h" #ifndef M_PI #define M_PI 3.14159265358979323846264338327950288 @@ -45,36 +47,14 @@ RacingControlComponent::RacingControlComponent(Entity* parent) m_EmptyTimer = 0; m_SoloRacing = Game::config->GetValue("solo_racing") == "1"; - // Select the main world ID as fallback when a player fails to load. - + m_MainWorld = 1200; const auto worldID = Game::server->GetZoneID(); + if (dZoneManager::Instance()->CheckIfAccessibleZone((worldID/10)*10)) m_MainWorld = (worldID/10)*10; - switch (worldID) { - case 1203: - m_ActivityID = 42; - m_MainWorld = 1200; - break; - - case 1261: - m_ActivityID = 60; - m_MainWorld = 1260; - break; - - case 1303: - m_ActivityID = 39; - m_MainWorld = 1300; - break; - - case 1403: - m_ActivityID = 54; - m_MainWorld = 1400; - break; - - default: - m_ActivityID = 42; - m_MainWorld = 1200; - break; - } + m_ActivityID = 42; + CDActivitiesTable* activitiesTable = CDClientManager::Instance().GetTable(); + std::vector activities = activitiesTable->Query([=](CDActivities entry) {return (entry.instanceMapID == worldID); }); + for (CDActivities activity : activities) m_ActivityID = activity.ActivityID; } RacingControlComponent::~RacingControlComponent() {} @@ -311,7 +291,7 @@ void RacingControlComponent::OnRequestDie(Entity* player) { if (!racingPlayer.noSmashOnReload) { racingPlayer.smashedTimes++; GameMessages::SendDie(vehicle, vehicle->GetObjectID(), LWOOBJID_EMPTY, true, - VIOLENT, u"", 0, 0, 90.0f, false, true, 0); + eKillType::VIOLENT, u"", 0, 0, 90.0f, false, true, 0); auto* destroyableComponent = vehicle->GetComponent(); uint32_t respawnImagination = 0; @@ -382,8 +362,7 @@ void RacingControlComponent::OnRacingPlayerInfoResetFinished(Entity* player) { } } -void RacingControlComponent::HandleMessageBoxResponse(Entity* player, - const std::string& id) { +void RacingControlComponent::HandleMessageBoxResponse(Entity* player, int32_t button, const std::string& id) { auto* data = GetPlayerData(player->GetObjectID()); if (data == nullptr) { @@ -425,7 +404,7 @@ void RacingControlComponent::HandleMessageBoxResponse(Entity* player, missionComponent->Progress(eMissionTaskType::RACING, dZoneManager::Instance()->GetZone()->GetWorldID(), (LWOOBJID)eRacingTaskParam::LAST_PLACE_FINISH); // Finished first place in specific world. } } - } else if (id == "ACT_RACE_EXIT_THE_RACE?" || id == "Exit") { + } else if ((id == "ACT_RACE_EXIT_THE_RACE?" || id == "Exit") && button == m_ActivityExitConfirm) { auto* vehicle = EntityManager::Instance()->GetEntity(data->vehicleID); if (vehicle == nullptr) { @@ -765,7 +744,7 @@ void RacingControlComponent::Update(float deltaTime) { // be smashed by death plane if (vehiclePosition.y < -500) { GameMessages::SendDie(vehicle, m_Parent->GetObjectID(), - LWOOBJID_EMPTY, true, VIOLENT, u"", 0, 0, 0, + LWOOBJID_EMPTY, true, eKillType::VIOLENT, u"", 0, 0, 0, true, false, 0); OnRequestDie(playerEntity); diff --git a/dGame/dComponents/RacingControlComponent.h b/dGame/dComponents/RacingControlComponent.h index 91ab2fd4..a81121e1 100644 --- a/dGame/dComponents/RacingControlComponent.h +++ b/dGame/dComponents/RacingControlComponent.h @@ -144,7 +144,7 @@ public: /** * Invoked when the player responds to the GUI. */ - void HandleMessageBoxResponse(Entity* player, const std::string& id); + void HandleMessageBoxResponse(Entity* player, int32_t button, const std::string& id); /** * Get the racing data from a player's LWOOBJID. @@ -246,4 +246,9 @@ private: float m_EmptyTimer; bool m_SoloRacing; + + /** + * Value for message box response to know if we are exiting the race via the activity dialogue + */ + const int32_t m_ActivityExitConfirm = 1; }; diff --git a/dGame/dComponents/RailActivatorComponent.cpp b/dGame/dComponents/RailActivatorComponent.cpp index 2a12caf8..8e13c37f 100644 --- a/dGame/dComponents/RailActivatorComponent.cpp +++ b/dGame/dComponents/RailActivatorComponent.cpp @@ -9,6 +9,7 @@ #include "dLogger.h" #include "RenderComponent.h" #include "EntityManager.h" +#include "eStateChangeType.h" RailActivatorComponent::RailActivatorComponent(Entity* parent, int32_t componentID) : Component(parent) { m_ComponentID = componentID; @@ -43,7 +44,7 @@ RailActivatorComponent::~RailActivatorComponent() = default; void RailActivatorComponent::OnUse(Entity* originator) { auto* rebuildComponent = m_Parent->GetComponent(); - if (rebuildComponent != nullptr && rebuildComponent->GetState() != REBUILD_COMPLETED) + if (rebuildComponent != nullptr && rebuildComponent->GetState() != eRebuildState::COMPLETED) return; if (rebuildComponent != nullptr) { diff --git a/dGame/dComponents/RebuildComponent.cpp b/dGame/dComponents/RebuildComponent.cpp index 6f2e9eab..39c8fe8d 100644 --- a/dGame/dComponents/RebuildComponent.cpp +++ b/dGame/dComponents/RebuildComponent.cpp @@ -9,6 +9,9 @@ #include "MissionComponent.h" #include "eMissionTaskType.h" #include "eTriggerEventType.h" +#include "eQuickBuildFailReason.h" +#include "eTerminateType.h" +#include "eGameActivity.h" #include "dServer.h" #include "PacketUtils.h" @@ -48,7 +51,7 @@ RebuildComponent::~RebuildComponent() { Entity* builder = GetBuilder(); if (builder) { - CancelRebuild(builder, eFailReason::REASON_BUILD_ENDED, true); + CancelRebuild(builder, eQuickBuildFailReason::BUILD_ENDED, true); } DespawnActivator(); @@ -67,7 +70,7 @@ void RebuildComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitia // If build state is completed and we've already serialized once in the completed state, // don't serializing this component anymore as this will cause the build to jump again. // If state changes, serialization will begin again. - if (!m_StateDirty && m_State == REBUILD_COMPLETED) { + if (!m_StateDirty && m_State == eRebuildState::COMPLETED) { outBitStream->Write0(); outBitStream->Write0(); return; @@ -91,7 +94,7 @@ void RebuildComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitia outBitStream->Write1(); - outBitStream->Write(m_State); + outBitStream->Write(m_State); outBitStream->Write(m_ShowResetEffect); outBitStream->Write(m_Activator != nullptr); @@ -121,7 +124,7 @@ void RebuildComponent::Update(float deltaTime) { }*/ switch (m_State) { - case REBUILD_OPEN: { + case eRebuildState::OPEN: { SpawnActivator(); m_TimeBeforeDrain = 0; @@ -151,7 +154,7 @@ void RebuildComponent::Update(float deltaTime) { break; } - case REBUILD_COMPLETED: { + case eRebuildState::COMPLETED: { m_Timer += deltaTime; // For reset times < 0 this has to be handled manually @@ -173,7 +176,7 @@ void RebuildComponent::Update(float deltaTime) { } break; } - case REBUILD_BUILDING: + case eRebuildState::BUILDING: { Entity* builder = GetBuilder(); @@ -194,18 +197,18 @@ void RebuildComponent::Update(float deltaTime) { DestroyableComponent* destComp = builder->GetComponent(); if (!destComp) break; - int newImagination = destComp->GetImagination() - 1; + int newImagination = destComp->GetImagination(); + if (newImagination <= 0) { + CancelRebuild(builder, eQuickBuildFailReason::OUT_OF_IMAGINATION, true); + break; + } + ++m_DrainedImagination; + --newImagination; destComp->SetImagination(newImagination); EntityManager::Instance()->SerializeEntity(builder); - ++m_DrainedImagination; - if (newImagination == 0 && m_DrainedImagination < m_TakeImagination) { - CancelRebuild(builder, eFailReason::REASON_OUT_OF_IMAGINATION, true); - - break; - } } if (m_Timer >= m_CompleteTime && m_DrainedImagination >= m_TakeImagination) { @@ -214,7 +217,7 @@ void RebuildComponent::Update(float deltaTime) { break; } - case REBUILD_INCOMPLETE: { + case eRebuildState::INCOMPLETE: { m_TimerIncomplete += deltaTime; // For reset times < 0 this has to be handled manually @@ -235,11 +238,12 @@ void RebuildComponent::Update(float deltaTime) { } break; } + case eRebuildState::RESETTING: break; } } void RebuildComponent::OnUse(Entity* originator) { - if (GetBuilder() != nullptr || m_State == REBUILD_COMPLETED) { + if (GetBuilder() != nullptr || m_State == eRebuildState::COMPLETED) { return; } @@ -393,18 +397,18 @@ void RebuildComponent::SetRepositionPlayer(bool value) { } void RebuildComponent::StartRebuild(Entity* user) { - if (m_State == eRebuildState::REBUILD_OPEN || m_State == eRebuildState::REBUILD_COMPLETED || m_State == eRebuildState::REBUILD_INCOMPLETE) { + if (m_State == eRebuildState::OPEN || m_State == eRebuildState::COMPLETED || m_State == eRebuildState::INCOMPLETE) { m_Builder = user->GetObjectID(); auto* character = user->GetComponent(); - character->SetCurrentActivity(eGameActivities::ACTIVITY_QUICKBUILDING); + character->SetCurrentActivity(eGameActivity::QUICKBUILDING); EntityManager::Instance()->SerializeEntity(user); - GameMessages::SendRebuildNotifyState(m_Parent, m_State, eRebuildState::REBUILD_BUILDING, user->GetObjectID()); - GameMessages::SendEnableRebuild(m_Parent, true, false, false, eFailReason::REASON_NOT_GIVEN, 0.0f, user->GetObjectID()); + GameMessages::SendRebuildNotifyState(m_Parent, m_State, eRebuildState::BUILDING, user->GetObjectID()); + GameMessages::SendEnableRebuild(m_Parent, true, false, false, eQuickBuildFailReason::NOT_GIVEN, 0.0f, user->GetObjectID()); - m_State = eRebuildState::REBUILD_BUILDING; + m_State = eRebuildState::BUILDING; m_StateDirty = true; EntityManager::Instance()->SerializeEntity(m_Parent); @@ -432,7 +436,7 @@ void RebuildComponent::CompleteRebuild(Entity* user) { auto* characterComponent = user->GetComponent(); if (characterComponent != nullptr) { - characterComponent->SetCurrentActivity(eGameActivities::ACTIVITY_NONE); + characterComponent->SetCurrentActivity(eGameActivity::NONE); characterComponent->TrackRebuildComplete(); } else { Game::logger->Log("RebuildComponent", "Some user tried to finish the rebuild but they didn't have a character somehow."); @@ -441,13 +445,13 @@ void RebuildComponent::CompleteRebuild(Entity* user) { EntityManager::Instance()->SerializeEntity(user); - GameMessages::SendRebuildNotifyState(m_Parent, m_State, eRebuildState::REBUILD_COMPLETED, user->GetObjectID()); + GameMessages::SendRebuildNotifyState(m_Parent, m_State, eRebuildState::COMPLETED, user->GetObjectID()); GameMessages::SendPlayFXEffect(m_Parent, 507, u"create", "BrickFadeUpVisCompleteEffect", LWOOBJID_EMPTY, 0.4f, 1.0f, true); - GameMessages::SendEnableRebuild(m_Parent, false, false, true, eFailReason::REASON_NOT_GIVEN, m_ResetTime, user->GetObjectID()); + GameMessages::SendEnableRebuild(m_Parent, false, false, true, eQuickBuildFailReason::NOT_GIVEN, m_ResetTime, user->GetObjectID()); GameMessages::SendTerminateInteraction(user->GetObjectID(), eTerminateType::FROM_INTERACTION, m_Parent->GetObjectID()); - m_State = eRebuildState::REBUILD_COMPLETED; + m_State = eRebuildState::COMPLETED; m_StateDirty = true; m_Timer = 0.0f; m_DrainedImagination = 0; @@ -520,17 +524,17 @@ void RebuildComponent::CompleteRebuild(Entity* user) { void RebuildComponent::ResetRebuild(bool failed) { Entity* builder = GetBuilder(); - if (m_State == eRebuildState::REBUILD_BUILDING && builder) { - GameMessages::SendEnableRebuild(m_Parent, false, false, failed, eFailReason::REASON_NOT_GIVEN, m_ResetTime, builder->GetObjectID()); + if (m_State == eRebuildState::BUILDING && builder) { + GameMessages::SendEnableRebuild(m_Parent, false, false, failed, eQuickBuildFailReason::NOT_GIVEN, m_ResetTime, builder->GetObjectID()); if (failed) { RenderComponent::PlayAnimation(builder, u"rebuild-fail"); } } - GameMessages::SendRebuildNotifyState(m_Parent, m_State, eRebuildState::REBUILD_RESETTING, LWOOBJID_EMPTY); + GameMessages::SendRebuildNotifyState(m_Parent, m_State, eRebuildState::RESETTING, LWOOBJID_EMPTY); - m_State = eRebuildState::REBUILD_RESETTING; + m_State = eRebuildState::RESETTING; m_StateDirty = true; m_Timer = 0.0f; m_TimerIncomplete = 0.0f; @@ -552,15 +556,15 @@ void RebuildComponent::ResetRebuild(bool failed) { } } -void RebuildComponent::CancelRebuild(Entity* entity, eFailReason failReason, bool skipChecks) { - if (m_State != eRebuildState::REBUILD_COMPLETED || skipChecks) { +void RebuildComponent::CancelRebuild(Entity* entity, eQuickBuildFailReason failReason, bool skipChecks) { + if (m_State != eRebuildState::COMPLETED || skipChecks) { m_Builder = LWOOBJID_EMPTY; const auto entityID = entity != nullptr ? entity->GetObjectID() : LWOOBJID_EMPTY; // Notify the client that a state has changed - GameMessages::SendRebuildNotifyState(m_Parent, m_State, eRebuildState::REBUILD_INCOMPLETE, entityID); + GameMessages::SendRebuildNotifyState(m_Parent, m_State, eRebuildState::INCOMPLETE, entityID); GameMessages::SendEnableRebuild(m_Parent, false, true, false, failReason, m_Timer, entityID); // Now terminate any interaction with the rebuild @@ -568,7 +572,7 @@ void RebuildComponent::CancelRebuild(Entity* entity, eFailReason failReason, boo GameMessages::SendTerminateInteraction(m_Parent->GetObjectID(), eTerminateType::FROM_INTERACTION, m_Parent->GetObjectID()); // Now update the component itself - m_State = eRebuildState::REBUILD_INCOMPLETE; + m_State = eRebuildState::INCOMPLETE; m_StateDirty = true; // Notify scripts and possible subscribers @@ -586,7 +590,7 @@ void RebuildComponent::CancelRebuild(Entity* entity, eFailReason failReason, boo CharacterComponent* characterComponent = entity->GetComponent(); if (characterComponent) { - characterComponent->SetCurrentActivity(eGameActivities::ACTIVITY_NONE); + characterComponent->SetCurrentActivity(eGameActivity::NONE); EntityManager::Instance()->SerializeEntity(entity); } } diff --git a/dGame/dComponents/RebuildComponent.h b/dGame/dComponents/RebuildComponent.h index a8e11e4c..09dd0465 100644 --- a/dGame/dComponents/RebuildComponent.h +++ b/dGame/dComponents/RebuildComponent.h @@ -10,8 +10,10 @@ #include "Preconditions.h" #include "Component.h" #include "eReplicaComponentType.h" +#include "eRebuildState.h" class Entity; +enum class eQuickBuildFailReason : uint32_t; /** * Component that handles entities that can be built into other entities using the quick build mechanic. Generally @@ -215,7 +217,7 @@ public: * @param failReason the reason the rebuild was cancelled * @param skipChecks whether or not to skip the check for the rebuild not being completed */ - void CancelRebuild(Entity* builder, eFailReason failReason, bool skipChecks = false); + void CancelRebuild(Entity* builder, eQuickBuildFailReason failReason, bool skipChecks = false); private: /** * Whether or not the quickbuild state has been changed since we last serialized it. @@ -225,7 +227,7 @@ private: /** * The state the rebuild is currently in */ - eRebuildState m_State = eRebuildState::REBUILD_OPEN; + eRebuildState m_State = eRebuildState::OPEN; /** * The time that has passed since initiating the rebuild diff --git a/dGame/dComponents/RenderComponent.h b/dGame/dComponents/RenderComponent.h index a0b21919..cdf32160 100644 --- a/dGame/dComponents/RenderComponent.h +++ b/dGame/dComponents/RenderComponent.h @@ -6,7 +6,7 @@ #include #include -#include "AMFFormat.h" +#include "Amf3.h" #include "Component.h" #include "eReplicaComponentType.h" diff --git a/dGame/dComponents/RocketLaunchpadControlComponent.cpp b/dGame/dComponents/RocketLaunchpadControlComponent.cpp index 4f248a40..3cac9e42 100644 --- a/dGame/dComponents/RocketLaunchpadControlComponent.cpp +++ b/dGame/dComponents/RocketLaunchpadControlComponent.cpp @@ -15,8 +15,10 @@ #include "PropertyEntranceComponent.h" #include "RocketLaunchLupComponent.h" #include "dServer.h" -#include "dMessageIdentifiers.h" #include "PacketUtils.h" +#include "eObjectWorldState.h" +#include "eConnectionType.h" +#include "eMasterMessageType.h" RocketLaunchpadControlComponent::RocketLaunchpadControlComponent(Entity* parent, int rocketId) : Component(parent) { auto query = CDClientDatabase::CreatePreppedStmt( @@ -77,7 +79,7 @@ void RocketLaunchpadControlComponent::Launch(Entity* originator, LWOMAPID mapId, GameMessages::SendFireEventClientSide(m_Parent->GetObjectID(), originator->GetSystemAddress(), u"RocketEquipped", rocket->GetId(), cloneId, -1, originator->GetObjectID()); - GameMessages::SendChangeObjectWorldState(rocket->GetId(), WORLDSTATE_ATTACHED, UNASSIGNED_SYSTEM_ADDRESS); + GameMessages::SendChangeObjectWorldState(rocket->GetId(), eObjectWorldState::ATTACHED, UNASSIGNED_SYSTEM_ADDRESS); EntityManager::Instance()->SerializeEntity(originator); } @@ -135,7 +137,7 @@ LWOCLONEID RocketLaunchpadControlComponent::GetSelectedCloneId(LWOOBJID player) void RocketLaunchpadControlComponent::TellMasterToPrepZone(int zoneID) { CBITSTREAM; - PacketUtils::WriteHeader(bitStream, MASTER, MSG_MASTER_PREP_ZONE); + PacketUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::PREP_ZONE); bitStream.Write(zoneID); Game::server->SendToMaster(&bitStream); } diff --git a/dGame/dComponents/ScriptedActivityComponent.cpp b/dGame/dComponents/ScriptedActivityComponent.cpp index 1bc8c01f..555332f4 100644 --- a/dGame/dComponents/ScriptedActivityComponent.cpp +++ b/dGame/dComponents/ScriptedActivityComponent.cpp @@ -18,13 +18,16 @@ #include "dConfig.h" #include "InventoryComponent.h" #include "DestroyableComponent.h" -#include "dMessageIdentifiers.h" #include "Loot.h" #include "eMissionTaskType.h" +#include "eMatchUpdate.h" +#include "eConnectionType.h" +#include "eChatInternalMessageType.h" #include "CDCurrencyTableTable.h" #include "CDActivityRewardsTable.h" #include "CDActivitiesTable.h" +#include "LeaderboardManager.h" ScriptedActivityComponent::ScriptedActivityComponent(Entity* parent, int activityID) : Component(parent) { m_ActivityID = activityID; @@ -33,10 +36,7 @@ ScriptedActivityComponent::ScriptedActivityComponent(Entity* parent, int activit for (CDActivities activity : activities) { m_ActivityInfo = activity; - - const auto mapID = m_ActivityInfo.instanceMapID; - - if ((mapID == 1203 || mapID == 1261 || mapID == 1303 || mapID == 1403) && Game::config->GetValue("solo_racing") == "1") { + if (static_cast(activity.leaderboardType) == LeaderboardType::Racing && Game::config->GetValue("solo_racing") == "1") { m_ActivityInfo.minTeamSize = 1; m_ActivityInfo.minTeams = 1; } @@ -167,9 +167,9 @@ void ScriptedActivityComponent::PlayerJoinLobby(Entity* player) { } std::string matchUpdate = "player=9:" + std::to_string(entity->GetObjectID()) + "\nplayerName=0:" + entity->GetCharacter()->GetName(); - GameMessages::SendMatchUpdate(player, player->GetSystemAddress(), matchUpdate, eMatchUpdate::MATCH_UPDATE_PLAYER_JOINED); + GameMessages::SendMatchUpdate(player, player->GetSystemAddress(), matchUpdate, eMatchUpdate::PLAYER_ADDED); PlayerReady(entity, joinedPlayer->ready); - GameMessages::SendMatchUpdate(entity, entity->GetSystemAddress(), matchUpdateJoined, eMatchUpdate::MATCH_UPDATE_PLAYER_JOINED); + GameMessages::SendMatchUpdate(entity, entity->GetSystemAddress(), matchUpdateJoined, eMatchUpdate::PLAYER_ADDED); } } } @@ -185,7 +185,7 @@ void ScriptedActivityComponent::PlayerJoinLobby(Entity* player) { if (m_ActivityInfo.maxTeamSize != 1 && playerLobby->players.size() >= m_ActivityInfo.minTeamSize || m_ActivityInfo.maxTeamSize == 1 && playerLobby->players.size() >= m_ActivityInfo.minTeams) { // Update the joining player on the match timer std::string matchTimerUpdate = "time=3:" + std::to_string(playerLobby->timer); - GameMessages::SendMatchUpdate(player, player->GetSystemAddress(), matchTimerUpdate, eMatchUpdate::MATCH_UPDATE_TIME); + GameMessages::SendMatchUpdate(player, player->GetSystemAddress(), matchTimerUpdate, eMatchUpdate::PHASE_WAIT_READY); } } @@ -201,7 +201,7 @@ void ScriptedActivityComponent::PlayerLeave(LWOOBJID playerID) { if (entity == nullptr) continue; - GameMessages::SendMatchUpdate(entity, entity->GetSystemAddress(), matchUpdateLeft, eMatchUpdate::MATCH_UPDATE_PLAYER_LEFT); + GameMessages::SendMatchUpdate(entity, entity->GetSystemAddress(), matchUpdateLeft, eMatchUpdate::PLAYER_REMOVED); } delete lobby->players[i]; @@ -242,7 +242,7 @@ void ScriptedActivityComponent::Update(float deltaTime) { continue; std::string matchTimerUpdate = "time=3:" + std::to_string(lobby->timer); - GameMessages::SendMatchUpdate(entity, entity->GetSystemAddress(), matchTimerUpdate, eMatchUpdate::MATCH_UPDATE_TIME); + GameMessages::SendMatchUpdate(entity, entity->GetSystemAddress(), matchTimerUpdate, eMatchUpdate::PHASE_WAIT_READY); } } @@ -267,7 +267,7 @@ void ScriptedActivityComponent::Update(float deltaTime) { if (entity == nullptr) continue; - GameMessages::SendMatchUpdate(entity, entity->GetSystemAddress(), matchTimerUpdate, eMatchUpdate::MATCH_UPDATE_TIME_START_DELAY); + GameMessages::SendMatchUpdate(entity, entity->GetSystemAddress(), matchTimerUpdate, eMatchUpdate::PHASE_WAIT_START); } } @@ -375,8 +375,8 @@ void ScriptedActivityComponent::PlayerReady(Entity* player, bool bReady) { // Update players in lobby on player being ready std::string matchReadyUpdate = "player=9:" + std::to_string(player->GetObjectID()); - eMatchUpdate readyStatus = eMatchUpdate::MATCH_UPDATE_PLAYER_READY; - if (!bReady) readyStatus = eMatchUpdate::MATCH_UPDATE_PLAYER_UNREADY; + eMatchUpdate readyStatus = eMatchUpdate::PLAYER_READY; + if (!bReady) readyStatus = eMatchUpdate::PLAYER_NOT_READY; for (LobbyPlayer* otherPlayer : lobby->players) { auto* entity = otherPlayer->GetEntity(); if (entity == nullptr) @@ -516,7 +516,7 @@ void ActivityInstance::StartZone() { // only make a team if we have more than one participant if (participants.size() > 1) { CBITSTREAM; - PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_CREATE_TEAM); + PacketUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::CREATE_TEAM); bitStream.Write(leader->GetObjectID()); bitStream.Write(m_Participants.size()); diff --git a/dGame/dComponents/SkillComponent.cpp b/dGame/dComponents/SkillComponent.cpp index 23ef1bee..c2f07425 100644 --- a/dGame/dComponents/SkillComponent.cpp +++ b/dGame/dComponents/SkillComponent.cpp @@ -20,11 +20,11 @@ #include "ScriptComponent.h" #include "BuffComponent.h" #include "EchoStartSkill.h" -#include "dMessageIdentifiers.h" #include "DoClientProjectileImpact.h" #include "CDClientManager.h" - #include "CDSkillBehaviorTable.h" +#include "eConnectionType.h" +#include "eClientMessageType.h" ProjectileSyncEntry::ProjectileSyncEntry() { } @@ -134,6 +134,10 @@ void SkillComponent::Update(const float deltaTime) { CalculateUpdate(deltaTime); } + if (m_Parent->IsPlayer()) { + for (const auto& pair : this->m_managedBehaviors) pair.second->UpdatePlayerSyncs(deltaTime); + } + std::map keep{}; for (const auto& pair : this->m_managedBehaviors) { @@ -192,7 +196,15 @@ void SkillComponent::Interrupt() { auto* combat = m_Parent->GetComponent(); if (combat != nullptr && combat->GetStunImmune()) return; - for (const auto& behavior : this->m_managedBehaviors) behavior.second->Interrupt(); + for (const auto& behavior : this->m_managedBehaviors) { + for (const auto& behaviorEndEntry : behavior.second->endEntries) { + behaviorEndEntry.behavior->End(behavior.second, behaviorEndEntry.branchContext, behaviorEndEntry.second); + } + behavior.second->endEntries.clear(); + if (m_Parent->IsPlayer()) continue; + behavior.second->Interrupt(); + } + } void SkillComponent::RegisterCalculatedProjectile(const LWOOBJID projectileId, BehaviorContext* context, const BehaviorBranchContext& branch, const LOT lot, const float maxTime, @@ -215,7 +227,7 @@ void SkillComponent::RegisterCalculatedProjectile(const LWOOBJID projectileId, B this->m_managedProjectiles.push_back(entry); } -bool SkillComponent::CastSkill(const uint32_t skillId, LWOOBJID target, const LWOOBJID optionalOriginatorID){ +bool SkillComponent::CastSkill(const uint32_t skillId, LWOOBJID target, const LWOOBJID optionalOriginatorID) { uint32_t behaviorId = -1; // try to find it via the cache const auto& pair = m_skillBehaviorCache.find(skillId); @@ -248,6 +260,8 @@ SkillExecutionResult SkillComponent::CalculateBehavior(const uint32_t skillId, c context->caster = m_Parent->GetObjectID(); + context->skillID = skillId; + context->clientInitalized = clientInitalized; context->foundTarget = target != LWOOBJID_EMPTY || ignoreTarget || clientInitalized; @@ -290,7 +304,7 @@ SkillExecutionResult SkillComponent::CalculateBehavior(const uint32_t skillId, c // Write message RakNet::BitStream message; - PacketUtils::WriteHeader(message, CLIENT, MSG_CLIENT_GAME_MSG); + PacketUtils::WriteHeader(message, eConnectionType::CLIENT, eClientMessageType::GAME_MSG); message.Write(this->m_Parent->GetObjectID()); start.Serialize(&message); @@ -423,7 +437,7 @@ void SkillComponent::SyncProjectileCalculation(const ProjectileSyncEntry& entry) RakNet::BitStream message; - PacketUtils::WriteHeader(message, CLIENT, MSG_CLIENT_GAME_MSG); + PacketUtils::WriteHeader(message, eConnectionType::CLIENT, eClientMessageType::GAME_MSG); message.Write(this->m_Parent->GetObjectID()); projectileImpact.Serialize(&message); @@ -463,7 +477,7 @@ void SkillComponent::HandleUnCast(const uint32_t behaviorId, const LWOOBJID targ delete context; } -SkillComponent::SkillComponent(Entity* parent) : Component(parent) { +SkillComponent::SkillComponent(Entity* parent): Component(parent) { this->m_skillUid = 0; } diff --git a/dGame/dComponents/SwitchComponent.cpp b/dGame/dComponents/SwitchComponent.cpp index 131a7d52..b393bbef 100644 --- a/dGame/dComponents/SwitchComponent.cpp +++ b/dGame/dComponents/SwitchComponent.cpp @@ -40,7 +40,7 @@ bool SwitchComponent::GetActive() const { void SwitchComponent::EntityEnter(Entity* entity) { if (!m_Active) { if (m_Rebuild) { - if (m_Rebuild->GetState() != eRebuildState::REBUILD_COMPLETED) return; + if (m_Rebuild->GetState() != eRebuildState::COMPLETED) return; } m_Active = true; if (!m_Parent) return; diff --git a/dGame/dComponents/TriggerComponent.cpp b/dGame/dComponents/TriggerComponent.cpp index 0f241116..7adf47a8 100644 --- a/dGame/dComponents/TriggerComponent.cpp +++ b/dGame/dComponents/TriggerComponent.cpp @@ -83,8 +83,12 @@ void TriggerComponent::HandleTriggerCommand(LUTriggers::Command* command, Entity case eTriggerCommandType::REPEL_OBJECT: HandleRepelObject(targetEntity, command->args); break; - case eTriggerCommandType::SET_TIMER: break; - case eTriggerCommandType::CANCEL_TIMER: break; + case eTriggerCommandType::SET_TIMER: + HandleSetTimer(targetEntity, argArray); + break; + case eTriggerCommandType::CANCEL_TIMER: + HandleCancelTimer(targetEntity, command->args); + break; case eTriggerCommandType::PLAY_CINEMATIC: HandlePlayCinematic(targetEntity, argArray); break; @@ -194,7 +198,7 @@ void TriggerComponent::HandleDestroyObject(Entity* targetEntity, std::string arg void TriggerComponent::HandleToggleTrigger(Entity* targetEntity, std::string args){ auto* triggerComponent = targetEntity->GetComponent(); if (!triggerComponent) { - Game::logger->Log("TriggerComponent::HandleToggleTrigger", "Trigger component not found!"); + Game::logger->LogDebug("TriggerComponent::HandleToggleTrigger", "Trigger component not found!"); return; } triggerComponent->SetTriggerEnabled(args == "1"); @@ -203,7 +207,7 @@ void TriggerComponent::HandleToggleTrigger(Entity* targetEntity, std::string arg void TriggerComponent::HandleResetRebuild(Entity* targetEntity, std::string args){ auto* rebuildComponent = targetEntity->GetComponent(); if (!rebuildComponent) { - Game::logger->Log("TriggerComponent::HandleResetRebuild", "Rebuild component not found!"); + Game::logger->LogDebug("TriggerComponent::HandleResetRebuild", "Rebuild component not found!"); return; } rebuildComponent->ResetRebuild(args == "1"); @@ -231,9 +235,11 @@ void TriggerComponent::HandleRotateObject(Entity* targetEntity, std::vector argArray){ + if (argArray.size() < 3) return; + auto* phantomPhysicsComponent = m_Parent->GetComponent(); if (!phantomPhysicsComponent) { - Game::logger->Log("TriggerComponent::HandlePushObject", "Phantom Physics component not found!"); + Game::logger->LogDebug("TriggerComponent::HandlePushObject", "Phantom Physics component not found!"); return; } phantomPhysicsComponent->SetPhysicsEffectActive(true); @@ -250,7 +256,7 @@ void TriggerComponent::HandlePushObject(Entity* targetEntity, std::vectorGetComponent(); if (!phantomPhysicsComponent) { - Game::logger->Log("TriggerComponent::HandleRepelObject", "Phantom Physics component not found!"); + Game::logger->LogDebug("TriggerComponent::HandleRepelObject", "Phantom Physics component not found!"); return; } float forceMultiplier; @@ -271,6 +277,20 @@ void TriggerComponent::HandleRepelObject(Entity* targetEntity, std::string args) EntityManager::Instance()->SerializeEntity(m_Parent); } +void TriggerComponent::HandleSetTimer(Entity* targetEntity, std::vector argArray){ + if (argArray.size() != 2) { + Game::logger->LogDebug("TriggerComponent::HandleSetTimer", "Not ehought variables!"); + return; + } + float time = 0.0; + GeneralUtils::TryParse(argArray.at(1), time); + m_Parent->AddTimer(argArray.at(0), time); +} + +void TriggerComponent::HandleCancelTimer(Entity* targetEntity, std::string args){ + m_Parent->CancelTimer(args); +} + void TriggerComponent::HandlePlayCinematic(Entity* targetEntity, std::vector argArray) { float leadIn = -1.0; auto wait = eEndBehavior::RETURN; @@ -300,7 +320,7 @@ void TriggerComponent::HandlePlayCinematic(Entity* targetEntity, std::vectorGetCharacter(); if (!character) { - Game::logger->Log("TriggerComponent::HandleToggleBBB", "Character was not found!"); + Game::logger->LogDebug("TriggerComponent::HandleToggleBBB", "Character was not found!"); return; } bool buildMode = !(character->GetBuildMode()); @@ -316,7 +336,7 @@ void TriggerComponent::HandleUpdateMission(Entity* targetEntity, std::vectorGetComponent(); if (!missionComponent){ - Game::logger->Log("TriggerComponent::HandleUpdateMission", "Mission component not found!"); + Game::logger->LogDebug("TriggerComponent::HandleUpdateMission", "Mission component not found!"); return; } missionComponent->Progress(eMissionTaskType::EXPLORE, 0, 0, argArray.at(4)); @@ -335,7 +355,7 @@ void TriggerComponent::HandlePlayEffect(Entity* targetEntity, std::vectorGetComponent(); if (!skillComponent) { - Game::logger->Log("TriggerComponent::HandleCastSkill", "Skill component not found!"); + Game::logger->LogDebug("TriggerComponent::HandleCastSkill", "Skill component not found!"); return; } uint32_t skillId; @@ -346,7 +366,7 @@ void TriggerComponent::HandleCastSkill(Entity* targetEntity, std::string args){ void TriggerComponent::HandleSetPhysicsVolumeEffect(Entity* targetEntity, std::vector argArray) { auto* phantomPhysicsComponent = targetEntity->GetComponent(); if (!phantomPhysicsComponent) { - Game::logger->Log("TriggerComponent::HandleSetPhysicsVolumeEffect", "Phantom Physics component not found!"); + Game::logger->LogDebug("TriggerComponent::HandleSetPhysicsVolumeEffect", "Phantom Physics component not found!"); return; } phantomPhysicsComponent->SetPhysicsEffectActive(true); @@ -381,7 +401,7 @@ void TriggerComponent::HandleSetPhysicsVolumeEffect(Entity* targetEntity, std::v void TriggerComponent::HandleSetPhysicsVolumeStatus(Entity* targetEntity, std::string args) { auto* phantomPhysicsComponent = targetEntity->GetComponent(); if (!phantomPhysicsComponent) { - Game::logger->Log("TriggerComponent::HandleSetPhysicsVolumeEffect", "Phantom Physics component not found!"); + Game::logger->LogDebug("TriggerComponent::HandleSetPhysicsVolumeEffect", "Phantom Physics component not found!"); return; } phantomPhysicsComponent->SetPhysicsEffectActive(args == "On"); diff --git a/dGame/dComponents/TriggerComponent.h b/dGame/dComponents/TriggerComponent.h index 317da00e..df65707f 100644 --- a/dGame/dComponents/TriggerComponent.h +++ b/dGame/dComponents/TriggerComponent.h @@ -30,6 +30,8 @@ private: void HandleRotateObject(Entity* targetEntity, std::vector argArray); void HandlePushObject(Entity* targetEntity, std::vector argArray); void HandleRepelObject(Entity* targetEntity, std::string args); + void HandleSetTimer(Entity* targetEntity, std::vector argArray); + void HandleCancelTimer(Entity* targetEntity, std::string args); void HandlePlayCinematic(Entity* targetEntity, std::vector argArray); void HandleToggleBBB(Entity* targetEntity, std::string args); void HandleUpdateMission(Entity* targetEntity, std::vector argArray); diff --git a/dGame/dComponents/VehiclePhysicsComponent.cpp b/dGame/dComponents/VehiclePhysicsComponent.cpp index bf6a3bb7..d981acf7 100644 --- a/dGame/dComponents/VehiclePhysicsComponent.cpp +++ b/dGame/dComponents/VehiclePhysicsComponent.cpp @@ -11,6 +11,7 @@ VehiclePhysicsComponent::VehiclePhysicsComponent(Entity* parent) : Component(par m_DirtyPosition = true; m_DirtyVelocity = true; m_DirtyAngularVelocity = true; + m_EndBehavior = GeneralUtils::GenerateRandomNumber(0, 7); } VehiclePhysicsComponent::~VehiclePhysicsComponent() { @@ -93,7 +94,7 @@ void VehiclePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bool bI } if (bIsInitialUpdate) { - outBitStream->Write(5); + outBitStream->Write(m_EndBehavior); outBitStream->Write1(); } diff --git a/dGame/dComponents/VehiclePhysicsComponent.h b/dGame/dComponents/VehiclePhysicsComponent.h index 551cce42..64609edf 100644 --- a/dGame/dComponents/VehiclePhysicsComponent.h +++ b/dGame/dComponents/VehiclePhysicsComponent.h @@ -109,4 +109,5 @@ private: bool m_IsOnRail; float m_SoftUpdate = 0; + uint32_t m_EndBehavior; }; diff --git a/dGame/dGameMessages/DoClientProjectileImpact.h b/dGame/dGameMessages/DoClientProjectileImpact.h index 436e3dd2..6b381aa5 100644 --- a/dGame/dGameMessages/DoClientProjectileImpact.h +++ b/dGame/dGameMessages/DoClientProjectileImpact.h @@ -1,13 +1,10 @@ #ifndef __DOCLIENTPROJECTILEIMPACT__H__ #define __DOCLIENTPROJECTILEIMPACT__H__ -#include "dMessageIdentifiers.h" #include "dCommonVars.h" /* Tell a client local projectile to impact */ class DoClientProjectileImpact { - static const GAME_MSG MsgID = GAME_MSG_DO_CLIENT_PROJECTILE_IMPACT; - public: DoClientProjectileImpact() { i64OrgID = LWOOBJID_EMPTY; @@ -30,7 +27,7 @@ public: } void Serialize(RakNet::BitStream* stream) { - stream->Write(MsgID); + stream->Write(eGameMessageType::DO_CLIENT_PROJECTILE_IMPACT); stream->Write(i64OrgID != LWOOBJID_EMPTY); if (i64OrgID != LWOOBJID_EMPTY) stream->Write(i64OrgID); diff --git a/dGame/dGameMessages/EchoStartSkill.h b/dGame/dGameMessages/EchoStartSkill.h index 6d912798..f5dee816 100644 --- a/dGame/dGameMessages/EchoStartSkill.h +++ b/dGame/dGameMessages/EchoStartSkill.h @@ -2,14 +2,12 @@ #define __ECHOSTARTSKILL__H__ #include "dCommonVars.h" -#include "dMessageIdentifiers.h" #include "NiPoint3.h" #include "NiQuaternion.h" +#include "eGameMessageType.h" /* Same as start skill but with different network options. An echo down to other clients that need to play the skill. */ class EchoStartSkill { - static const GAME_MSG MsgID = GAME_MSG_ECHO_START_SKILL; - public: EchoStartSkill() { bUsedMouse = false; @@ -42,7 +40,7 @@ public: } void Serialize(RakNet::BitStream* stream) { - stream->Write(MsgID); + stream->Write(eGameMessageType::ECHO_START_SKILL); stream->Write(bUsedMouse); diff --git a/dGame/dGameMessages/EchoSyncSkill.h b/dGame/dGameMessages/EchoSyncSkill.h index b56beae8..ab5a3f2b 100644 --- a/dGame/dGameMessages/EchoSyncSkill.h +++ b/dGame/dGameMessages/EchoSyncSkill.h @@ -4,13 +4,11 @@ #include #include "BitStream.h" +#include "eGameMessageType.h" -#include "dMessageIdentifiers.h" /* Message to synchronize a skill cast */ class EchoSyncSkill { - static const GAME_MSG MsgID = GAME_MSG_ECHO_SYNC_SKILL; - public: EchoSyncSkill() { bDone = false; @@ -31,7 +29,7 @@ public: } void Serialize(RakNet::BitStream* stream) { - stream->Write(MsgID); + stream->Write(eGameMessageType::ECHO_SYNC_SKILL); stream->Write(bDone); uint32_t sBitStreamLength = sBitStream.length(); diff --git a/dGame/dGameMessages/GameMessageHandler.cpp b/dGame/dGameMessages/GameMessageHandler.cpp index c0893a09..be751598 100644 --- a/dGame/dGameMessages/GameMessageHandler.cpp +++ b/dGame/dGameMessages/GameMessageHandler.cpp @@ -33,10 +33,11 @@ #include "EchoSyncSkill.h" #include "eMissionTaskType.h" #include "eReplicaComponentType.h" +#include "eConnectionType.h" using namespace std; -void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const SystemAddress& sysAddr, LWOOBJID objectID, GAME_MSG messageID) { +void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const SystemAddress& sysAddr, LWOOBJID objectID, eGameMessageType messageID) { CBITSTREAM; @@ -53,54 +54,54 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System switch (messageID) { - case GAME_MSG_UN_USE_BBB_MODEL: { + case eGameMessageType::UN_USE_BBB_MODEL: { GameMessages::HandleUnUseModel(inStream, entity, sysAddr); break; } - case GAME_MSG_PLAY_EMOTE: { + case eGameMessageType::PLAY_EMOTE: { GameMessages::HandlePlayEmote(inStream, entity); break; } - case GAME_MSG_MOVE_ITEM_IN_INVENTORY: { + case eGameMessageType::MOVE_ITEM_IN_INVENTORY: { GameMessages::HandleMoveItemInInventory(inStream, entity); break; } - case GAME_MSG_REMOVE_ITEM_FROM_INVENTORY: { + case eGameMessageType::REMOVE_ITEM_FROM_INVENTORY: { GameMessages::HandleRemoveItemFromInventory(inStream, entity, sysAddr); break; } - case GAME_MSG_EQUIP_ITEM: + case eGameMessageType::EQUIP_ITEM: GameMessages::HandleEquipItem(inStream, entity); break; - case GAME_MSG_UN_EQUIP_ITEM: + case eGameMessageType::UN_EQUIP_ITEM: GameMessages::HandleUnequipItem(inStream, entity); break; - case GAME_MSG_RESPOND_TO_MISSION: { + case eGameMessageType::RESPOND_TO_MISSION: { GameMessages::HandleRespondToMission(inStream, entity); break; } - case GAME_MSG_REQUEST_USE: { + case eGameMessageType::REQUEST_USE: { GameMessages::HandleRequestUse(inStream, entity, sysAddr); break; } - case GAME_MSG_SET_FLAG: { + case eGameMessageType::SET_FLAG: { GameMessages::HandleSetFlag(inStream, entity); break; } - case GAME_MSG_HAS_BEEN_COLLECTED: { + case eGameMessageType::HAS_BEEN_COLLECTED: { GameMessages::HandleHasBeenCollected(inStream, entity); break; } - case GAME_MSG_PLAYER_LOADED: { + case eGameMessageType::PLAYER_LOADED: { GameMessages::SendRestoreToPostLoadStats(entity, sysAddr); entity->SetPlayerReadyForUpdates(); @@ -174,73 +175,73 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System break; } - case GAME_MSG_REQUEST_LINKED_MISSION: { + case eGameMessageType::REQUEST_LINKED_MISSION: { GameMessages::HandleRequestLinkedMission(inStream, entity); break; } - case GAME_MSG_MISSION_DIALOGUE_OK: { + case eGameMessageType::MISSION_DIALOGUE_OK: { GameMessages::HandleMissionDialogOK(inStream, entity); break; } - case GAME_MSG_MISSION_DIALOGUE_CANCELLED: { + case eGameMessageType::MISSION_DIALOGUE_CANCELLED: { //This message is pointless for our implementation, as the client just carries on after //rejecting a mission offer. We dont need to do anything. This is just here to remove a warning in our logs :) break; } - case GAME_MSG_REQUEST_PLATFORM_RESYNC: { + case eGameMessageType::REQUEST_PLATFORM_RESYNC: { GameMessages::HandleRequestPlatformResync(inStream, entity, sysAddr); break; } - case GAME_MSG_FIRE_EVENT_SERVER_SIDE: { + case eGameMessageType::FIRE_EVENT_SERVER_SIDE: { GameMessages::HandleFireEventServerSide(inStream, entity, sysAddr); break; } - case GAME_MSG_SEND_ACTIVITY_SUMMARY_LEADERBOARD_DATA: { + case eGameMessageType::SEND_ACTIVITY_SUMMARY_LEADERBOARD_DATA: { GameMessages::HandleActivitySummaryLeaderboardData(inStream, entity, sysAddr); break; } - case GAME_MSG_REQUEST_ACTIVITY_SUMMARY_LEADERBOARD_DATA: { + case eGameMessageType::REQUEST_ACTIVITY_SUMMARY_LEADERBOARD_DATA: { GameMessages::HandleRequestActivitySummaryLeaderboardData(inStream, entity, sysAddr); break; } - case GAME_MSG_ACTIVITY_STATE_CHANGE_REQUEST: { + case eGameMessageType::ACTIVITY_STATE_CHANGE_REQUEST: { GameMessages::HandleActivityStateChangeRequest(inStream, entity); break; } - case GAME_MSG_PARSE_CHAT_MESSAGE: { + case eGameMessageType::PARSE_CHAT_MESSAGE: { GameMessages::HandleParseChatMessage(inStream, entity, sysAddr); break; } - case GAME_MSG_NOTIFY_SERVER_LEVEL_PROCESSING_COMPLETE: { + case eGameMessageType::NOTIFY_SERVER_LEVEL_PROCESSING_COMPLETE: { GameMessages::HandleNotifyServerLevelProcessingComplete(inStream, entity); break; } - case GAME_MSG_PICKUP_CURRENCY: { + case eGameMessageType::PICKUP_CURRENCY: { GameMessages::HandlePickupCurrency(inStream, entity); break; } - case GAME_MSG_PICKUP_ITEM: { + case eGameMessageType::PICKUP_ITEM: { GameMessages::HandlePickupItem(inStream, entity); break; } - case GAME_MSG_RESURRECT: { + case eGameMessageType::RESURRECT: { GameMessages::HandleResurrect(inStream, entity); break; } - case GAME_MSG_REQUEST_RESURRECT: { + case eGameMessageType::REQUEST_RESURRECT: { GameMessages::SendResurrect(entity); /*auto* dest = static_cast(entity->GetComponent(eReplicaComponentType::DESTROYABLE)); if (dest) { @@ -251,12 +252,12 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System }*/ break; } - case GAME_MSG_HANDLE_HOT_PROPERTY_DATA: { + case eGameMessageType::HANDLE_HOT_PROPERTY_DATA: { GameMessages::HandleGetHotPropertyData(inStream, entity, sysAddr); break; } - case GAME_MSG_REQUEST_SERVER_PROJECTILE_IMPACT: + case eGameMessageType::REQUEST_SERVER_PROJECTILE_IMPACT: { auto message = RequestServerProjectileImpact(); @@ -275,7 +276,7 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System break; } - case GAME_MSG_START_SKILL: { + case eGameMessageType::START_SKILL: { StartSkill startSkill = StartSkill(); startSkill.Deserialize(inStream); // inStream replaces &bitStream @@ -313,7 +314,7 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System if (success) { //Broadcast our startSkill: RakNet::BitStream bitStreamLocal; - PacketUtils::WriteHeader(bitStreamLocal, CLIENT, MSG_CLIENT_GAME_MSG); + PacketUtils::WriteHeader(bitStreamLocal, eConnectionType::CLIENT, eClientMessageType::GAME_MSG); bitStreamLocal.Write(entity->GetObjectID()); EchoStartSkill echoStartSkill; @@ -333,11 +334,11 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System } } break; - case GAME_MSG_SYNC_SKILL: { + case eGameMessageType::SYNC_SKILL: { RakNet::BitStream bitStreamLocal; - PacketUtils::WriteHeader(bitStreamLocal, CLIENT, MSG_CLIENT_GAME_MSG); + PacketUtils::WriteHeader(bitStreamLocal, eConnectionType::CLIENT, eClientMessageType::GAME_MSG); bitStreamLocal.Write(entity->GetObjectID()); - //bitStreamLocal.Write((unsigned short)GAME_MSG_ECHO_SYNC_SKILL); + //bitStreamLocal.Write((unsigned short)eGameMessageType::ECHO_SYNC_SKILL); //bitStreamLocal.Write(inStream); SyncSkill sync = SyncSkill(inStream); // inStream replaced &bitStream @@ -374,308 +375,311 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System Game::server->Send(&bitStreamLocal, sysAddr, true); } break; - case GAME_MSG_REQUEST_SMASH_PLAYER: + case eGameMessageType::REQUEST_SMASH_PLAYER: entity->Smash(entity->GetObjectID()); break; - case GAME_MSG_MOVE_ITEM_BETWEEN_INVENTORY_TYPES: + case eGameMessageType::MOVE_ITEM_BETWEEN_INVENTORY_TYPES: GameMessages::HandleMoveItemBetweenInventoryTypes(inStream, entity, sysAddr); break; - case GAME_MSG_MODULAR_BUILD_FINISH: + case eGameMessageType::MODULAR_BUILD_FINISH: GameMessages::HandleModularBuildFinish(inStream, entity, sysAddr); break; - case GAME_MSG_PUSH_EQUIPPED_ITEMS_STATE: + case eGameMessageType::PUSH_EQUIPPED_ITEMS_STATE: GameMessages::HandlePushEquippedItemsState(inStream, entity); break; - case GAME_MSG_POP_EQUIPPED_ITEMS_STATE: + case eGameMessageType::POP_EQUIPPED_ITEMS_STATE: GameMessages::HandlePopEquippedItemsState(inStream, entity); break; - case GAME_MSG_BUY_FROM_VENDOR: + case eGameMessageType::BUY_FROM_VENDOR: GameMessages::HandleBuyFromVendor(inStream, entity, sysAddr); break; - case GAME_MSG_SELL_TO_VENDOR: + case eGameMessageType::SELL_TO_VENDOR: GameMessages::HandleSellToVendor(inStream, entity, sysAddr); break; - case GAME_MSG_BUYBACK_FROM_VENDOR: + case eGameMessageType::BUYBACK_FROM_VENDOR: GameMessages::HandleBuybackFromVendor(inStream, entity, sysAddr); break; - case GAME_MSG_MODULAR_BUILD_MOVE_AND_EQUIP: + case eGameMessageType::MODULAR_BUILD_MOVE_AND_EQUIP: GameMessages::HandleModularBuildMoveAndEquip(inStream, entity, sysAddr); break; - case GAME_MSG_DONE_ARRANGING_WITH_ITEM: + case eGameMessageType::DONE_ARRANGING_WITH_ITEM: GameMessages::HandleDoneArrangingWithItem(inStream, entity, sysAddr); break; - case GAME_MSG_MODULAR_BUILD_CONVERT_MODEL: + case eGameMessageType::MODULAR_BUILD_CONVERT_MODEL: GameMessages::HandleModularBuildConvertModel(inStream, entity, sysAddr); break; - case GAME_MSG_BUILD_MODE_SET: + case eGameMessageType::BUILD_MODE_SET: GameMessages::HandleBuildModeSet(inStream, entity); break; - case GAME_MSG_REBUILD_CANCEL: + case eGameMessageType::REBUILD_CANCEL: GameMessages::HandleRebuildCancel(inStream, entity); break; - case GAME_MSG_MATCH_REQUEST: + case eGameMessageType::MATCH_REQUEST: GameMessages::HandleMatchRequest(inStream, entity); break; - case GAME_MSG_USE_NON_EQUIPMENT_ITEM: + case eGameMessageType::USE_NON_EQUIPMENT_ITEM: GameMessages::HandleUseNonEquipmentItem(inStream, entity); break; - case GAME_MSG_CLIENT_ITEM_CONSUMED: + case eGameMessageType::CLIENT_ITEM_CONSUMED: GameMessages::HandleClientItemConsumed(inStream, entity); break; - case GAME_MSG_SET_CONSUMABLE_ITEM: + case eGameMessageType::SET_CONSUMABLE_ITEM: GameMessages::HandleSetConsumableItem(inStream, entity, sysAddr); break; - case GAME_MSG_VERIFY_ACK: + case eGameMessageType::VERIFY_ACK: GameMessages::HandleVerifyAck(inStream, entity, sysAddr); break; // Trading - case GAME_MSG_CLIENT_TRADE_REQUEST: + case eGameMessageType::CLIENT_TRADE_REQUEST: GameMessages::HandleClientTradeRequest(inStream, entity, sysAddr); break; - case GAME_MSG_CLIENT_TRADE_CANCEL: + case eGameMessageType::CLIENT_TRADE_CANCEL: GameMessages::HandleClientTradeCancel(inStream, entity, sysAddr); break; - case GAME_MSG_CLIENT_TRADE_ACCEPT: + case eGameMessageType::CLIENT_TRADE_ACCEPT: GameMessages::HandleClientTradeAccept(inStream, entity, sysAddr); break; - case GAME_MSG_CLIENT_TRADE_UPDATE: + case eGameMessageType::CLIENT_TRADE_UPDATE: GameMessages::HandleClientTradeUpdate(inStream, entity, sysAddr); break; // Pets - case GAME_MSG_PET_TAMING_TRY_BUILD: + case eGameMessageType::PET_TAMING_TRY_BUILD: GameMessages::HandlePetTamingTryBuild(inStream, entity, sysAddr); break; - case GAME_MSG_NOTIFY_TAMING_BUILD_SUCCESS: + case eGameMessageType::NOTIFY_TAMING_BUILD_SUCCESS: GameMessages::HandleNotifyTamingBuildSuccess(inStream, entity, sysAddr); break; - case GAME_MSG_REQUEST_SET_PET_NAME: + case eGameMessageType::REQUEST_SET_PET_NAME: GameMessages::HandleRequestSetPetName(inStream, entity, sysAddr); break; - case GAME_MSG_START_SERVER_PET_MINIGAME_TIMER: + case eGameMessageType::START_SERVER_PET_MINIGAME_TIMER: GameMessages::HandleStartServerPetMinigameTimer(inStream, entity, sysAddr); break; - case GAME_MSG_CLIENT_EXIT_TAMING_MINIGAME: + case eGameMessageType::CLIENT_EXIT_TAMING_MINIGAME: GameMessages::HandleClientExitTamingMinigame(inStream, entity, sysAddr); break; - case GAME_MSG_COMMAND_PET: + case eGameMessageType::COMMAND_PET: GameMessages::HandleCommandPet(inStream, entity, sysAddr); break; - case GAME_MSG_DESPAWN_PET: + case eGameMessageType::DESPAWN_PET: GameMessages::HandleDespawnPet(inStream, entity, sysAddr); break; - case GAME_MSG_MESSAGE_BOX_RESPOND: + case eGameMessageType::MESSAGE_BOX_RESPOND: GameMessages::HandleMessageBoxResponse(inStream, entity, sysAddr); break; - case GAME_MSG_CHOICE_BOX_RESPOND: + case eGameMessageType::CHOICE_BOX_RESPOND: GameMessages::HandleChoiceBoxRespond(inStream, entity, sysAddr); break; // Property - case GAME_MSG_QUERY_PROPERTY_DATA: + case eGameMessageType::QUERY_PROPERTY_DATA: GameMessages::HandleQueryPropertyData(inStream, entity, sysAddr); break; - case GAME_MSG_START_BUILDING_WITH_ITEM: + case eGameMessageType::START_BUILDING_WITH_ITEM: GameMessages::HandleStartBuildingWithItem(inStream, entity, sysAddr); break; - case GAME_MSG_SET_BUILD_MODE: + case eGameMessageType::SET_BUILD_MODE: GameMessages::HandleSetBuildMode(inStream, entity, sysAddr); break; - case GAME_MSG_PROPERTY_EDITOR_BEGIN: + case eGameMessageType::PROPERTY_EDITOR_BEGIN: GameMessages::HandlePropertyEditorBegin(inStream, entity, sysAddr); break; - case GAME_MSG_PROPERTY_EDITOR_END: + case eGameMessageType::PROPERTY_EDITOR_END: GameMessages::HandlePropertyEditorEnd(inStream, entity, sysAddr); break; - case GAME_MSG_PROPERTY_CONTENTS_FROM_CLIENT: + case eGameMessageType::PROPERTY_CONTENTS_FROM_CLIENT: GameMessages::HandlePropertyContentsFromClient(inStream, entity, sysAddr); break; - case GAME_MSG_ZONE_PROPERTY_MODEL_EQUIPPED: + case eGameMessageType::ZONE_PROPERTY_MODEL_EQUIPPED: GameMessages::HandlePropertyModelEquipped(inStream, entity, sysAddr); break; - case GAME_MSG_PLACE_PROPERTY_MODEL: + case eGameMessageType::PLACE_PROPERTY_MODEL: GameMessages::HandlePlacePropertyModel(inStream, entity, sysAddr); break; - case GAME_MSG_UPDATE_MODEL_FROM_CLIENT: + case eGameMessageType::UPDATE_MODEL_FROM_CLIENT: GameMessages::HandleUpdatePropertyModel(inStream, entity, sysAddr); break; - case GAME_MSG_DELETE_MODEL_FROM_CLIENT: + case eGameMessageType::DELETE_MODEL_FROM_CLIENT: GameMessages::HandleDeletePropertyModel(inStream, entity, sysAddr); break; - case GAME_MSG_BBB_LOAD_ITEM_REQUEST: + case eGameMessageType::BBB_LOAD_ITEM_REQUEST: GameMessages::HandleBBBLoadItemRequest(inStream, entity, sysAddr); break; - case GAME_MSG_BBB_SAVE_REQUEST: + case eGameMessageType::BBB_SAVE_REQUEST: GameMessages::HandleBBBSaveRequest(inStream, entity, sysAddr); break; - case GAME_MSG_CONTROL_BEHAVIOR: + case eGameMessageType::CONTROL_BEHAVIOR: GameMessages::HandleControlBehaviors(inStream, entity, sysAddr); break; - case GAME_MSG_PROPERTY_ENTRANCE_SYNC: + case eGameMessageType::PROPERTY_ENTRANCE_SYNC: GameMessages::HandlePropertyEntranceSync(inStream, entity, sysAddr); break; - case GAME_MSG_ENTER_PROPERTY1: + case eGameMessageType::ENTER_PROPERTY1: GameMessages::HandleEnterProperty(inStream, entity, sysAddr); break; - case GAME_MSG_ZONE_PROPERTY_MODEL_ROTATED: + case eGameMessageType::ZONE_PROPERTY_MODEL_ROTATED: EntityManager::Instance()->GetZoneControlEntity()->OnZonePropertyModelRotated(usr->GetLastUsedChar()->GetEntity()); break; - case GAME_MSG_UPDATE_PROPERTY_OR_MODEL_FOR_FILTER_CHECK: + case eGameMessageType::UPDATE_PROPERTY_OR_MODEL_FOR_FILTER_CHECK: GameMessages::HandleUpdatePropertyOrModelForFilterCheck(inStream, entity, sysAddr); break; - case GAME_MSG_SET_PROPERTY_ACCESS: + case eGameMessageType::SET_PROPERTY_ACCESS: GameMessages::HandleSetPropertyAccess(inStream, entity, sysAddr); break; // Racing - case GAME_MSG_MODULE_ASSEMBLY_QUERY_DATA: + case eGameMessageType::MODULE_ASSEMBLY_QUERY_DATA: GameMessages::HandleModuleAssemblyQueryData(inStream, entity, sysAddr); break; - case GAME_MSG_ACKNOWLEDGE_POSSESSION: + case eGameMessageType::ACKNOWLEDGE_POSSESSION: GameMessages::HandleAcknowledgePossession(inStream, entity, sysAddr); break; - case GAME_MSG_VEHICLE_SET_WHEEL_LOCK_STATE: + case eGameMessageType::VEHICLE_SET_WHEEL_LOCK_STATE: GameMessages::HandleVehicleSetWheelLockState(inStream, entity, sysAddr); break; - case GAME_MSG_MODULAR_ASSEMBLY_NIF_COMPLETED: + case eGameMessageType::MODULAR_ASSEMBLY_NIF_COMPLETED: GameMessages::HandleModularAssemblyNIFCompleted(inStream, entity, sysAddr); break; - case GAME_MSG_RACING_CLIENT_READY: + case eGameMessageType::RACING_CLIENT_READY: GameMessages::HandleRacingClientReady(inStream, entity, sysAddr); break; - case GAME_MSG_REQUEST_DIE: + case eGameMessageType::REQUEST_DIE: GameMessages::HandleRequestDie(inStream, entity, sysAddr); break; - case GAME_MSG_VEHICLE_NOTIFY_SERVER_ADD_PASSIVE_BOOST_ACTION: + case eGameMessageType::VEHICLE_NOTIFY_SERVER_ADD_PASSIVE_BOOST_ACTION: GameMessages::HandleVehicleNotifyServerAddPassiveBoostAction(inStream, entity, sysAddr); break; - case GAME_MSG_VEHICLE_NOTIFY_SERVER_REMOVE_PASSIVE_BOOST_ACTION: + case eGameMessageType::VEHICLE_NOTIFY_SERVER_REMOVE_PASSIVE_BOOST_ACTION: GameMessages::HandleVehicleNotifyServerRemovePassiveBoostAction(inStream, entity, sysAddr); break; - case GAME_MSG_RACING_PLAYER_INFO_RESET_FINISHED: + case eGameMessageType::RACING_PLAYER_INFO_RESET_FINISHED: GameMessages::HandleRacingPlayerInfoResetFinished(inStream, entity, sysAddr); break; - case GAME_MSG_VEHICLE_NOTIFY_HIT_IMAGINATION_SERVER: + case eGameMessageType::VEHICLE_NOTIFY_HIT_IMAGINATION_SERVER: GameMessages::HandleVehicleNotifyHitImaginationServer(inStream, entity, sysAddr); break; - case GAME_MSG_UPDATE_PROPERTY_PERFORMANCE_COST: + case eGameMessageType::UPDATE_PROPERTY_PERFORMANCE_COST: GameMessages::HandleUpdatePropertyPerformanceCost(inStream, entity, sysAddr); break; // SG - case GAME_MSG_UPDATE_SHOOTING_GALLERY_ROTATION: + case eGameMessageType::UPDATE_SHOOTING_GALLERY_ROTATION: GameMessages::HandleUpdateShootingGalleryRotation(inStream, entity, sysAddr); break; // NT - case GAME_MSG_REQUEST_MOVE_ITEM_BETWEEN_INVENTORY_TYPES: + case eGameMessageType::REQUEST_MOVE_ITEM_BETWEEN_INVENTORY_TYPES: GameMessages::HandleRequestMoveItemBetweenInventoryTypes(inStream, entity, sysAddr); break; - case GAME_MSG_TOGGLE_GHOST_REFERENCE_OVERRIDE: + case eGameMessageType::TOGGLE_GHOST_REFERENCE_OVERRIDE: GameMessages::HandleToggleGhostReferenceOverride(inStream, entity, sysAddr); break; - case GAME_MSG_SET_GHOST_REFERENCE_POSITION: + case eGameMessageType::SET_GHOST_REFERENCE_POSITION: GameMessages::HandleSetGhostReferencePosition(inStream, entity, sysAddr); break; - case GAME_MSG_READY_FOR_UPDATES: + case eGameMessageType::READY_FOR_UPDATES: //We don't really care about this message, as it's simply here to inform us that the client is done loading an object. //In the event we _do_ send an update to an object that hasn't finished loading, the client will handle it anyway. break; - case GAME_MSG_REPORT_BUG: + case eGameMessageType::REPORT_BUG: GameMessages::HandleReportBug(inStream, entity); break; - case GAME_MSG_CLIENT_RAIL_MOVEMENT_READY: + case eGameMessageType::CLIENT_RAIL_MOVEMENT_READY: GameMessages::HandleClientRailMovementReady(inStream, entity, sysAddr); break; - case GAME_MSG_CANCEL_RAIL_MOVEMENT: + case eGameMessageType::CANCEL_RAIL_MOVEMENT: GameMessages::HandleCancelRailMovement(inStream, entity, sysAddr); break; - case GAME_MSG_PLAYER_RAIL_ARRIVED_NOTIFICATION: + case eGameMessageType::PLAYER_RAIL_ARRIVED_NOTIFICATION: GameMessages::HandlePlayerRailArrivedNotification(inStream, entity, sysAddr); break; - case GAME_MSG_CINEMATIC_UPDATE: + case eGameMessageType::CINEMATIC_UPDATE: GameMessages::HandleCinematicUpdate(inStream, entity, sysAddr); break; - case GAME_MSG_MODIFY_PLAYER_ZONE_STATISTIC: + case eGameMessageType::MODIFY_PLAYER_ZONE_STATISTIC: GameMessages::HandleModifyPlayerZoneStatistic(inStream, entity); break; - case GAME_MSG_UPDATE_PLAYER_STATISTIC: + case eGameMessageType::UPDATE_PLAYER_STATISTIC: GameMessages::HandleUpdatePlayerStatistic(inStream, entity); break; - case GAME_MSG_DISMOUNT_COMPLETE: + case eGameMessageType::DISMOUNT_COMPLETE: GameMessages::HandleDismountComplete(inStream, entity, sysAddr); break; - case GAME_MSG_DEACTIVATE_BUBBLE_BUFF: + case eGameMessageType::DEACTIVATE_BUBBLE_BUFF: GameMessages::HandleDeactivateBubbleBuff(inStream, entity); break; - case GAME_MSG_ACTIVATE_BUBBLE_BUFF: + case eGameMessageType::ACTIVATE_BUBBLE_BUFF: GameMessages::HandleActivateBubbleBuff(inStream, entity); break; - case GAME_MSG_ZONE_SUMMARY_DISMISSED: + case eGameMessageType::ZONE_SUMMARY_DISMISSED: GameMessages::HandleZoneSummaryDismissed(inStream, entity); break; + case eGameMessageType::REQUEST_ACTIVITY_EXIT: + GameMessages::HandleRequestActivityExit(inStream, entity); + break; default: // Game::logger->Log("GameMessageHandler", "Unknown game message ID: %i", messageID); break; diff --git a/dGame/dGameMessages/GameMessageHandler.h b/dGame/dGameMessages/GameMessageHandler.h index 063e97f6..8b6685cb 100644 --- a/dGame/dGameMessages/GameMessageHandler.h +++ b/dGame/dGameMessages/GameMessageHandler.h @@ -7,7 +7,6 @@ #define GAMEMESSAGEHANDLER_H #include "RakNetTypes.h" -#include "dMessageIdentifiers.h" #include "dCommonVars.h" #include #include @@ -21,8 +20,10 @@ #include "GameMessages.h" #include "../dDatabase/CDClientDatabase.h" +enum class eGameMessageType : uint16_t; + namespace GameMessageHandler { - void HandleMessage(RakNet::BitStream* inStream, const SystemAddress& sysAddr, LWOOBJID objectID, GAME_MSG messageID); + void HandleMessage(RakNet::BitStream* inStream, const SystemAddress& sysAddr, LWOOBJID objectID, eGameMessageType messageID); }; #endif // GAMEMESSAGEHANDLER_H diff --git a/dGame/dGameMessages/GameMessages.cpp b/dGame/dGameMessages/GameMessages.cpp index b7af9188..f7bd3b7d 100644 --- a/dGame/dGameMessages/GameMessages.cpp +++ b/dGame/dGameMessages/GameMessages.cpp @@ -4,7 +4,6 @@ #include "PacketUtils.h" #include "BitStream.h" #include "Game.h" -#include "dMessageIdentifiers.h" #include "SlashCommandHandler.h" #include "NiPoint3.h" #include "NiQuaternion.h" @@ -29,13 +28,20 @@ #include "eUnequippableActiveType.h" #include "eMovementPlatformState.h" #include "LeaderboardManager.h" -#include "AMFFormat.h" +#include "Amf3.h" #include "Loot.h" #include "eRacingTaskParam.h" #include "eMissionTaskType.h" #include "eMissionState.h" -#include "RenderComponent.h" +#include "eObjectBits.h" #include "eTriggerEventType.h" +#include "eMatchUpdate.h" +#include "eCyclingMode.h" +#include "eCinematicEvent.h" +#include "eQuickBuildFailReason.h" +#include "eControlScheme.h" +#include "eStateChangeType.h" +#include "eConnectionType.h" #include #include @@ -81,8 +87,11 @@ #include "AMFDeserialize.h" #include "eBlueprintSaveResponseType.h" #include "eAninmationFlags.h" -#include "AMFFormat_BitStream.h" +#include "AmfSerialize.h" #include "eReplicaComponentType.h" +#include "eClientMessageType.h" +#include "eGameMessageType.h" +#include "ActivityManager.h" #include "CDComponentsRegistryTable.h" #include "CDObjectsTable.h" @@ -92,7 +101,7 @@ void GameMessages::SendFireEventClientSide(const LWOOBJID& objectID, const Syste CMSGHEADER; bitStream.Write(objectID); - bitStream.Write(GAME_MSG::GAME_MSG_FIRE_EVENT_CLIENT_SIDE); + bitStream.Write(eGameMessageType::FIRE_EVENT_CLIENT_SIDE); //bitStream.Write(args); uint32_t argSize = args.size(); @@ -114,7 +123,7 @@ void GameMessages::SendTeleport(const LWOOBJID& objectID, const NiPoint3& pos, c CBITSTREAM; CMSGHEADER; bitStream.Write(objectID); - bitStream.Write(GAME_MSG::GAME_MSG_TELEPORT); + bitStream.Write(eGameMessageType::TELEPORT); bool bIgnoreY = (pos.y == 0.0f); bool bUseNavmesh = false; @@ -152,7 +161,6 @@ void GameMessages::SendPlayAnimation(Entity* entity, const std::u16string& anima //Stolen from the old DLU codebase as the new one's autogenerated code doesn't work properly for animationIDs longer than 6 characters. CBITSTREAM; CMSGHEADER; - uint16_t gameMsgID = GAME_MSG_PLAY_ANIMATION; std::string sAnimationID = GeneralUtils::UTF16ToWTF8(animationName); uint32_t animationIDLength = sAnimationID.size(); @@ -161,7 +169,7 @@ void GameMessages::SendPlayAnimation(Entity* entity, const std::u16string& anima bool bTriggerOnCompleteMsg = false; bitStream.Write(entity->GetObjectID()); - bitStream.Write(gameMsgID); + bitStream.Write(eGameMessageType::PLAY_ANIMATION); bitStream.Write(animationIDLength); PacketUtils::WriteWString(bitStream, animationName, animationIDLength); @@ -185,7 +193,7 @@ void GameMessages::SendPlayerReady(Entity* entity, const SystemAddress& sysAddr) CBITSTREAM; CMSGHEADER; bitStream.Write(entity->GetObjectID()); - bitStream.Write(GAME_MSG::GAME_MSG_PLAYER_READY); + bitStream.Write(eGameMessageType::PLAYER_READY); SEND_PACKET; } @@ -194,7 +202,7 @@ void GameMessages::SendPlayerAllowedRespawn(LWOOBJID entityID, bool doNotPromptR CMSGHEADER; bitStream.Write(entityID); - bitStream.Write(GAME_MSG::GAME_MSG_SET_PLAYER_ALLOWED_RESPAWN); + bitStream.Write(eGameMessageType::SET_PLAYER_ALLOWED_RESPAWN); bitStream.Write(doNotPromptRespawn); SEND_PACKET; @@ -205,7 +213,7 @@ void GameMessages::SendInvalidZoneTransferList(Entity* entity, const SystemAddre CMSGHEADER; bitStream.Write(entity->GetObjectID()); - bitStream.Write(GAME_MSG::GAME_MSG_INVALID_ZONE_TRANSFER_LIST); + bitStream.Write(eGameMessageType::INVALID_ZONE_TRANSFER_LIST); uint32_t CustomerFeedbackURLLength = feedbackURL.size(); bitStream.Write(CustomerFeedbackURLLength); @@ -230,7 +238,7 @@ void GameMessages::SendKnockback(const LWOOBJID& objectID, const LWOOBJID& caste CMSGHEADER; bitStream.Write(objectID); - bitStream.Write(GAME_MSG_KNOCKBACK); + bitStream.Write(eGameMessageType::KNOCKBACK); bool casterFlag = caster != LWOOBJID_EMPTY; bool originatorFlag = originator != LWOOBJID_EMPTY; @@ -266,7 +274,7 @@ void GameMessages::SendStartArrangingWithItem( CMSGHEADER; bitStream.Write(entity->GetObjectID()); - bitStream.Write(GAME_MSG::GAME_MSG_START_ARRANGING_WITH_ITEM); + bitStream.Write(eGameMessageType::START_ARRANGING_WITH_ITEM); bitStream.Write(bFirstTime); bitStream.Write(buildAreaID != LWOOBJID_EMPTY); @@ -290,13 +298,13 @@ void GameMessages::SendPlayerSetCameraCyclingMode(const LWOOBJID& objectID, cons CMSGHEADER; bitStream.Write(objectID); - bitStream.Write(GAME_MSG_PLAYER_SET_CAMERA_CYCLING_MODE); + bitStream.Write(eGameMessageType::PLAYER_SET_CAMERA_CYCLING_MODE); bitStream.Write(bAllowCyclingWhileDeadOnly); - bitStream.Write(cyclingMode != ALLOW_CYCLE_TEAMMATES); - if (cyclingMode != ALLOW_CYCLE_TEAMMATES) { - bitStream.Write(cyclingMode); + bitStream.Write(cyclingMode != eCyclingMode::ALLOW_CYCLE_TEAMMATES); + if (cyclingMode != eCyclingMode::ALLOW_CYCLE_TEAMMATES) { + bitStream.Write(cyclingMode); } SEND_PACKET; @@ -307,7 +315,7 @@ void GameMessages::SendPlayNDAudioEmitter(Entity* entity, const SystemAddress& s CMSGHEADER; bitStream.Write(entity->GetObjectID()); - bitStream.Write((uint16_t)GAME_MSG_PLAY_ND_AUDIO_EMITTER); + bitStream.Write((uint16_t)eGameMessageType::PLAY_ND_AUDIO_EMITTER); bitStream.Write0(); bitStream.Write0(); @@ -336,7 +344,7 @@ void GameMessages::SendStartPathing(Entity* entity) { CMSGHEADER; bitStream.Write(entity->GetObjectID()); - bitStream.Write(GAME_MSG_START_PATHING); + bitStream.Write(eGameMessageType::START_PATHING); SEND_PACKET_BROADCAST; } @@ -358,7 +366,7 @@ void GameMessages::SendPlatformResync(Entity* entity, const SystemAddress& sysAd } bitStream.Write(entity->GetObjectID()); - bitStream.Write((uint16_t)GAME_MSG_PLATFORM_RESYNC); + bitStream.Write((uint16_t)eGameMessageType::PLATFORM_RESYNC); bool bReverse = false; int eCommand = 0; @@ -399,7 +407,7 @@ void GameMessages::SendRestoreToPostLoadStats(Entity* entity, const SystemAddres CBITSTREAM; CMSGHEADER; bitStream.Write(entity->GetObjectID()); - bitStream.Write(GAME_MSG::GAME_MSG_RESTORE_TO_POST_LOAD_STATS); + bitStream.Write(eGameMessageType::RESTORE_TO_POST_LOAD_STATS); SEND_PACKET; } @@ -407,7 +415,7 @@ void GameMessages::SendServerDoneLoadingAllObjects(Entity* entity, const SystemA CBITSTREAM; CMSGHEADER; bitStream.Write(entity->GetObjectID()); - bitStream.Write(GAME_MSG::GAME_MSG_SERVER_DONE_LOADING_ALL_OBJECTS); + bitStream.Write(eGameMessageType::SERVER_DONE_LOADING_ALL_OBJECTS); SEND_PACKET; } @@ -415,7 +423,7 @@ void GameMessages::SendChatModeUpdate(const LWOOBJID& objectID, eGameMasterLevel CBITSTREAM; CMSGHEADER; bitStream.Write(objectID); - bitStream.Write((uint16_t)GAME_MSG_UPDATE_CHAT_MODE); + bitStream.Write((uint16_t)eGameMessageType::UPDATE_CHAT_MODE); bitStream.Write(level); SEND_PACKET_BROADCAST; } @@ -424,7 +432,7 @@ void GameMessages::SendGMLevelBroadcast(const LWOOBJID& objectID, eGameMasterLev CBITSTREAM; CMSGHEADER; bitStream.Write(objectID); - bitStream.Write((uint16_t)GAME_MSG_SET_GM_LEVEL); + bitStream.Write((uint16_t)eGameMessageType::SET_GM_LEVEL); bitStream.Write1(); bitStream.Write(level); SEND_PACKET_BROADCAST; @@ -435,13 +443,13 @@ void GameMessages::SendAddItemToInventoryClientSync(Entity* entity, const System CMSGHEADER; bitStream.Write(entity->GetObjectID()); - bitStream.Write(static_cast(GAME_MSG_ADD_ITEM_TO_INVENTORY_CLIENT_SYNC)); + bitStream.Write(eGameMessageType::ADD_ITEM_TO_INVENTORY_CLIENT_SYNC); bitStream.Write(item->GetBound()); bitStream.Write(item->GetInfo().isBOE); bitStream.Write(item->GetInfo().isBOP); - bitStream.Write(lootSourceType != eLootSourceType::LOOT_SOURCE_NONE); // Loot source - if (lootSourceType != eLootSourceType::LOOT_SOURCE_NONE) bitStream.Write(lootSourceType); + bitStream.Write(lootSourceType != eLootSourceType::NONE); // Loot source + if (lootSourceType != eLootSourceType::NONE) bitStream.Write(lootSourceType); LWONameValue extraInfo; auto config = item->GetConfig(); @@ -489,24 +497,24 @@ void GameMessages::SendAddItemToInventoryClientSync(Entity* entity, const System SEND_PACKET; } -void GameMessages::SendNotifyClientFlagChange(const LWOOBJID& objectID, int iFlagID, bool bFlag, const SystemAddress& sysAddr) { +void GameMessages::SendNotifyClientFlagChange(const LWOOBJID& objectID, uint32_t iFlagID, bool bFlag, const SystemAddress& sysAddr) { CBITSTREAM; CMSGHEADER; bitStream.Write(objectID); - bitStream.Write((uint16_t)GAME_MSG_NOTIFY_CLIENT_FLAG_CHANGE); + bitStream.Write((uint16_t)eGameMessageType::NOTIFY_CLIENT_FLAG_CHANGE); bitStream.Write(bFlag); bitStream.Write(iFlagID); SEND_PACKET; } -void GameMessages::SendChangeObjectWorldState(const LWOOBJID& objectID, int state, const SystemAddress& sysAddr) { +void GameMessages::SendChangeObjectWorldState(const LWOOBJID& objectID, eObjectWorldState state, const SystemAddress& sysAddr) { CBITSTREAM; CMSGHEADER; bitStream.Write(objectID); - bitStream.Write((uint16_t)GAME_MSG_CHANGE_OBJECT_WORLD_STATE); + bitStream.Write((uint16_t)eGameMessageType::CHANGE_OBJECT_WORLD_STATE); bitStream.Write(state); if (sysAddr == UNASSIGNED_SYSTEM_ADDRESS) SEND_PACKET_BROADCAST @@ -524,7 +532,7 @@ void GameMessages::SendOfferMission(const LWOOBJID& entity, const SystemAddress& CMSGHEADER; bitStream.Write(offererID); - bitStream.Write(uint16_t(GAME_MSG_OFFER_MISSION)); + bitStream.Write(eGameMessageType::OFFER_MISSION); bitStream.Write(missionID); bitStream.Write(offererID); @@ -535,7 +543,7 @@ void GameMessages::SendOfferMission(const LWOOBJID& entity, const SystemAddress& CMSGHEADER; bitStream.Write(entity); - bitStream.Write(uint16_t(GAME_MSG_OFFER_MISSION)); + bitStream.Write(eGameMessageType::OFFER_MISSION); bitStream.Write(missionID); bitStream.Write(offererID); @@ -548,7 +556,7 @@ void GameMessages::SendNotifyMission(Entity* entity, const SystemAddress& sysAdd CMSGHEADER; bitStream.Write(entity->GetObjectID()); - bitStream.Write(uint16_t(GAME_MSG_NOTIFY_MISSION)); + bitStream.Write(eGameMessageType::NOTIFY_MISSION); bitStream.Write(missionID); bitStream.Write(missionState); bitStream.Write(sendingRewards); @@ -561,7 +569,7 @@ void GameMessages::SendNotifyMissionTask(Entity* entity, const SystemAddress& sy CMSGHEADER; bitStream.Write(entity->GetObjectID()); - bitStream.Write((uint16_t)GAME_MSG_NOTIFY_MISSION_TASK); + bitStream.Write((uint16_t)eGameMessageType::NOTIFY_MISSION_TASK); bitStream.Write(missionID); bitStream.Write(taskMask); @@ -579,23 +587,23 @@ void GameMessages::SendModifyLEGOScore(Entity* entity, const SystemAddress& sysA CMSGHEADER; bitStream.Write(entity->GetObjectID()); - bitStream.Write((uint16_t)GAME_MSG_MODIFY_LEGO_SCORE); + bitStream.Write((uint16_t)eGameMessageType::MODIFY_LEGO_SCORE); bitStream.Write(score); - bitStream.Write(sourceType != eLootSourceType::LOOT_SOURCE_NONE); - if (sourceType != eLootSourceType::LOOT_SOURCE_NONE) bitStream.Write(sourceType); + bitStream.Write(sourceType != eLootSourceType::NONE); + if (sourceType != eLootSourceType::NONE) bitStream.Write(sourceType); SEND_PACKET; } -void GameMessages::SendUIMessageServerToSingleClient(Entity* entity, const SystemAddress& sysAddr, const std::string& message, AMFValue* args) { +void GameMessages::SendUIMessageServerToSingleClient(Entity* entity, const SystemAddress& sysAddr, const std::string& message, AMFBaseValue& args) { CBITSTREAM; CMSGHEADER; bitStream.Write(entity->GetObjectID()); - bitStream.Write((uint16_t)GAME_MSG_UI_MESSAGE_SERVER_TO_SINGLE_CLIENT); + bitStream.Write((uint16_t)eGameMessageType::UI_MESSAGE_SERVER_TO_SINGLE_CLIENT); - bitStream.Write(args); + bitStream.Write(args); uint32_t strMessageNameLength = message.size(); bitStream.Write(strMessageNameLength); @@ -606,15 +614,15 @@ void GameMessages::SendUIMessageServerToSingleClient(Entity* entity, const Syste SEND_PACKET; } -void GameMessages::SendUIMessageServerToAllClients(const std::string& message, AMFValue* args) { +void GameMessages::SendUIMessageServerToAllClients(const std::string& message, AMFBaseValue& args) { CBITSTREAM; CMSGHEADER; LWOOBJID empty = 0; bitStream.Write(empty); - bitStream.Write((uint16_t)GAME_MSG_UI_MESSAGE_SERVER_TO_ALL_CLIENTS); + bitStream.Write((uint16_t)eGameMessageType::UI_MESSAGE_SERVER_TO_ALL_CLIENTS); - bitStream.Write(args); + bitStream.Write(args); uint32_t strMessageNameLength = message.size(); bitStream.Write(strMessageNameLength); @@ -630,7 +638,7 @@ void GameMessages::SendPlayEmbeddedEffectOnAllClientsNearObject(Entity* entity, CMSGHEADER; bitStream.Write(entity->GetObjectID()); - bitStream.Write((uint16_t)GAME_MSG_PLAY_EMBEDDED_EFFECT_ON_ALL_CLIENTS_NEAR_OBJECT); + bitStream.Write((uint16_t)eGameMessageType::PLAY_EMBEDDED_EFFECT_ON_ALL_CLIENTS_NEAR_OBJECT); bitStream.Write(static_cast(effectName.length())); for (uint32_t k = 0; k < effectName.length(); k++) { @@ -651,7 +659,7 @@ void GameMessages::SendPlayFXEffect(const LWOOBJID& entity, int32_t effectID, co CMSGHEADER; bitStream.Write(entity); - bitStream.Write((uint16_t)GAME_MSG::GAME_MSG_PLAY_FX_EFFECT); + bitStream.Write((uint16_t)eGameMessageType::PLAY_FX_EFFECT); bitStream.Write(effectID != -1); if (effectID != -1) bitStream.Write(effectID); @@ -685,7 +693,7 @@ void GameMessages::SendStopFXEffect(Entity* entity, bool killImmediate, std::str CMSGHEADER; bitStream.Write(entity->GetObjectID()); - bitStream.Write(GAME_MSG::GAME_MSG_STOP_FX_EFFECT); + bitStream.Write(eGameMessageType::STOP_FX_EFFECT); bitStream.Write(killImmediate); bitStream.Write(name.size()); @@ -699,7 +707,7 @@ void GameMessages::SendBroadcastTextToChatbox(Entity* entity, const SystemAddres CMSGHEADER; bitStream.Write(entity->GetObjectID()); - bitStream.Write((uint16_t)GAME_MSG::GAME_MSG_BROADCAST_TEXT_TO_CHATBOX); + bitStream.Write((uint16_t)eGameMessageType::BROADCAST_TEXT_TO_CHATBOX); LWONameValue attribs; attribs.name = attrs; @@ -725,7 +733,7 @@ void GameMessages::SendSetCurrency(Entity* entity, int64_t currency, int lootTyp CMSGHEADER; bitStream.Write(entity->GetObjectID()); - bitStream.Write(uint16_t(GAME_MSG_SET_CURRENCY)); + bitStream.Write(eGameMessageType::SET_CURRENCY); bitStream.Write(currency); @@ -743,19 +751,19 @@ void GameMessages::SendSetCurrency(Entity* entity, int64_t currency, int lootTyp bitStream.Write(sourceTradeID != LWOOBJID_EMPTY); if (sourceTradeID != LWOOBJID_EMPTY) bitStream.Write(sourceTradeID); - bitStream.Write(sourceType != LOOTTYPE_NONE); - if (sourceType != LOOTTYPE_NONE) bitStream.Write(sourceType); + bitStream.Write(sourceType != eLootSourceType::NONE); + if (sourceType != eLootSourceType::NONE) bitStream.Write(sourceType); SystemAddress sysAddr = entity->GetSystemAddress(); SEND_PACKET; } -void GameMessages::SendRebuildNotifyState(Entity* entity, int prevState, int state, const LWOOBJID& playerID) { +void GameMessages::SendRebuildNotifyState(Entity* entity, eRebuildState prevState, eRebuildState state, const LWOOBJID& playerID) { CBITSTREAM; CMSGHEADER; bitStream.Write(entity->GetObjectID()); - bitStream.Write((uint16_t)GAME_MSG_REBUILD_NOTIFY_STATE); + bitStream.Write((uint16_t)eGameMessageType::REBUILD_NOTIFY_STATE); bitStream.Write(prevState); bitStream.Write(state); @@ -764,19 +772,19 @@ void GameMessages::SendRebuildNotifyState(Entity* entity, int prevState, int sta SEND_PACKET_BROADCAST; } -void GameMessages::SendEnableRebuild(Entity* entity, bool enable, bool fail, bool success, int failReason, float duration, const LWOOBJID& playerID) { +void GameMessages::SendEnableRebuild(Entity* entity, bool enable, bool fail, bool success, eQuickBuildFailReason failReason, float duration, const LWOOBJID& playerID) { CBITSTREAM; CMSGHEADER; bitStream.Write(entity->GetObjectID()); - bitStream.Write((uint16_t)GAME_MSG_ENABLE_REBUILD); + bitStream.Write((uint16_t)eGameMessageType::ENABLE_REBUILD); bitStream.Write(enable); bitStream.Write(fail); bitStream.Write(success); - bitStream.Write(failReason != eFailReason::REASON_NOT_GIVEN); - if (failReason != eFailReason::REASON_NOT_GIVEN) bitStream.Write(failReason); + bitStream.Write(failReason != eQuickBuildFailReason::NOT_GIVEN); + if (failReason != eQuickBuildFailReason::NOT_GIVEN) bitStream.Write(failReason); bitStream.Write(duration); bitStream.Write(playerID); @@ -789,7 +797,7 @@ void GameMessages::SendTerminateInteraction(const LWOOBJID& objectID, eTerminate CMSGHEADER; bitStream.Write(objectID); - bitStream.Write((uint16_t)GAME_MSG_TERMINATE_INTERACTION); + bitStream.Write((uint16_t)eGameMessageType::TERMINATE_INTERACTION); bitStream.Write(terminator); bitStream.Write(type); @@ -802,7 +810,7 @@ void GameMessages::SendDieNoImplCode(Entity* entity, const LWOOBJID& killerID, c CMSGHEADER; bitStream.Write(entity->GetObjectID()); - bitStream.Write(uint16_t(GAME_MSG_DIE)); + bitStream.Write(eGameMessageType::DIE); bitStream.Write(bClientDeath); bitStream.Write(bSpawnLoot); bitStream.Write(deathType); @@ -825,7 +833,7 @@ void GameMessages::SendDie(Entity* entity, const LWOOBJID& killerID, const LWOOB bitStream.Write(entity->GetObjectID()); - bitStream.Write((uint16_t)GAME_MSG_DIE); + bitStream.Write((uint16_t)eGameMessageType::DIE); bitStream.Write(bClientDeath); bitStream.Write(bSpawnLoot); @@ -843,8 +851,8 @@ void GameMessages::SendDie(Entity* entity, const LWOOBJID& killerID, const LWOOB bitStream.Write(directionRelative_AngleY); bitStream.Write(directionRelative_Force); - bitStream.Write(killType != VIOLENT); - if (killType != VIOLENT) bitStream.Write(killType); + bitStream.Write(killType != eKillType::VIOLENT); + if (killType != eKillType::VIOLENT) bitStream.Write(killType); bitStream.Write(killerID); @@ -861,7 +869,7 @@ void GameMessages::SendSetInventorySize(Entity* entity, int invType, int size) { CMSGHEADER; bitStream.Write(entity->GetObjectID()); - bitStream.Write(uint16_t(GAME_MSG_SET_INVENTORY_SIZE)); + bitStream.Write(eGameMessageType::SET_INVENTORY_SIZE); bitStream.Write(invType); bitStream.Write(size); @@ -874,7 +882,7 @@ void GameMessages::SendSetEmoteLockState(Entity* entity, bool bLock, int emoteID CMSGHEADER; bitStream.Write(entity->GetObjectID()); - bitStream.Write(uint16_t(GAME_MSG_SET_EMOTE_LOCK_STATE)); + bitStream.Write(eGameMessageType::SET_EMOTE_LOCK_STATE); bitStream.Write(bLock); bitStream.Write(emoteID); @@ -895,7 +903,7 @@ void GameMessages::SendSetJetPackMode(Entity* entity, bool use, bool bypassCheck CMSGHEADER; bitStream.Write(entity->GetObjectID()); - bitStream.Write(uint16_t(GAME_MSG_SET_JET_PACK_MODE)); + bitStream.Write(eGameMessageType::SET_JET_PACK_MODE); bitStream.Write(bypassChecks); bitStream.Write(doHover); @@ -931,8 +939,13 @@ void GameMessages::SendResurrect(Entity* entity) { if (destroyableComponent != nullptr && entity->GetLOT() == 1) { auto* levelComponent = entity->GetComponent(); if (levelComponent) { - destroyableComponent->SetHealth(levelComponent->GetLevel() >= 45 ? 8 : 4); - destroyableComponent->SetImagination(levelComponent->GetLevel() >= 45 ? 20 : 6); + int32_t healthToRestore = levelComponent->GetLevel() >= 45 ? 8 : 4; + if (healthToRestore > destroyableComponent->GetMaxHealth()) healthToRestore = destroyableComponent->GetMaxHealth(); + destroyableComponent->SetHealth(healthToRestore); + + int32_t imaginationToRestore = levelComponent->GetLevel() >= 45 ? 20 : 6; + if (imaginationToRestore > destroyableComponent->GetMaxImagination()) imaginationToRestore = destroyableComponent->GetMaxImagination(); + destroyableComponent->SetImagination(imaginationToRestore); } } }); @@ -950,7 +963,7 @@ void GameMessages::SendResurrect(Entity* entity) { bool bRezImmediately = false; bitStream.Write(entity->GetObjectID()); - bitStream.Write(uint16_t(GAME_MSG_RESURRECT)); + bitStream.Write(eGameMessageType::RESURRECT); bitStream.Write(bRezImmediately); SEND_PACKET_BROADCAST; @@ -961,7 +974,7 @@ void GameMessages::SendStop2DAmbientSound(Entity* entity, bool force, std::strin CMSGHEADER; bitStream.Write(entity->GetObjectID()); - bitStream.Write((uint16_t)GAME_MSG_PLAY2_DAMBIENT_SOUND); + bitStream.Write((uint16_t)eGameMessageType::PLAY2_DAMBIENT_SOUND); uint32_t audioGUIDSize = audioGUID.size(); @@ -984,7 +997,7 @@ void GameMessages::SendPlay2DAmbientSound(Entity* entity, std::string audioGUID, CMSGHEADER; bitStream.Write(entity->GetObjectID()); - bitStream.Write((uint16_t)GAME_MSG_PLAY2_DAMBIENT_SOUND); + bitStream.Write((uint16_t)eGameMessageType::PLAY2_DAMBIENT_SOUND); uint32_t audioGUIDSize = audioGUID.size(); @@ -1003,7 +1016,7 @@ void GameMessages::SendSetNetworkScriptVar(Entity* entity, const SystemAddress& CMSGHEADER; bitStream.Write(entity->GetObjectID()); - bitStream.Write((uint16_t)GAME_MSG_SET_NETWORK_SCRIPT_VAR); + bitStream.Write((uint16_t)eGameMessageType::SET_NETWORK_SCRIPT_VAR); // FIXME: this is a bad place to need to do a conversion because we have no clue whether data is utf8 or plain ascii // an this has performance implications @@ -1062,7 +1075,7 @@ void GameMessages::SendDropClientLoot(Entity* entity, const LWOOBJID& sourceID, CMSGHEADER; bitStream.Write(entity->GetObjectID()); - bitStream.Write(uint16_t(GAME_MSG_DROP_CLIENT_LOOT)); + bitStream.Write(eGameMessageType::DROP_CLIENT_LOOT); bitStream.Write(bUsePosition); @@ -1104,7 +1117,7 @@ void GameMessages::SendDropClientLoot(Entity* entity, const LWOOBJID& sourceID, SEND_PACKET; } -void GameMessages::SendSetPlayerControlScheme(Entity* entity, eControlSceme controlScheme) { +void GameMessages::SendSetPlayerControlScheme(Entity* entity, eControlScheme controlScheme) { CBITSTREAM; CMSGHEADER; @@ -1112,13 +1125,13 @@ void GameMessages::SendSetPlayerControlScheme(Entity* entity, eControlSceme cont bool bSwitchCam = true; bitStream.Write(entity->GetObjectID()); - bitStream.Write(uint16_t(GAME_MSG_SET_PLAYER_CONTROL_SCHEME)); + bitStream.Write(eGameMessageType::SET_PLAYER_CONTROL_SCHEME); bitStream.Write(bDelayCamSwitchIfInCinematic); bitStream.Write(bSwitchCam); - bitStream.Write(controlScheme != SCHEME_A); - if (controlScheme != SCHEME_A) bitStream.Write(controlScheme); + bitStream.Write(controlScheme != eControlScheme::SCHEME_A); + if (controlScheme != eControlScheme::SCHEME_A) bitStream.Write(controlScheme); SystemAddress sysAddr = entity->GetSystemAddress(); SEND_PACKET; @@ -1129,7 +1142,7 @@ void GameMessages::SendPlayerReachedRespawnCheckpoint(Entity* entity, const NiPo CMSGHEADER; bitStream.Write(entity->GetObjectID()); - bitStream.Write((uint16_t)GAME_MSG_PLAYER_REACHED_RESPAWN_CHECKPOINT); + bitStream.Write((uint16_t)eGameMessageType::PLAYER_REACHED_RESPAWN_CHECKPOINT); bitStream.Write(position.x); bitStream.Write(position.y); @@ -1163,7 +1176,7 @@ void GameMessages::SendAddSkill(Entity* entity, TSkillID skillID, int slotID) { CMSGHEADER; bitStream.Write(entity->GetObjectID()); - bitStream.Write((uint16_t)GAME_MSG_ADD_SKILL); + bitStream.Write((uint16_t)eGameMessageType::ADD_SKILL); bitStream.Write(AICombatWeight != 0); if (AICombatWeight != 0) bitStream.Write(AICombatWeight); @@ -1195,7 +1208,7 @@ void GameMessages::SendRemoveSkill(Entity* entity, TSkillID skillID) { CMSGHEADER; bitStream.Write(entity->GetObjectID()); - bitStream.Write(GAME_MSG_REMOVE_SKILL); + bitStream.Write(eGameMessageType::REMOVE_SKILL); bitStream.Write(false); bitStream.Write(skillID); @@ -1224,7 +1237,7 @@ void GameMessages::SendFinishArrangingWithItem(Entity* entity, const LWOOBJID& b bitStream.Write(entity->GetObjectID()); - bitStream.Write(GAME_MSG::GAME_MSG_FINISH_ARRANGING_WITH_ITEM); + bitStream.Write(eGameMessageType::FINISH_ARRANGING_WITH_ITEM); bitStream.Write(buildAreaID != LWOOBJID_EMPTY); if (buildAreaID != LWOOBJID_EMPTY) bitStream.Write(buildAreaID); @@ -1250,7 +1263,7 @@ void GameMessages::SendModularBuildEnd(Entity* entity) { CMSGHEADER; bitStream.Write(entity->GetObjectID()); - bitStream.Write(GAME_MSG::GAME_MSG_MODULAR_BUILD_END); + bitStream.Write(eGameMessageType::MODULAR_BUILD_END); SystemAddress sysAddr = entity->GetSystemAddress(); SEND_PACKET; @@ -1261,7 +1274,7 @@ void GameMessages::SendVendorOpenWindow(Entity* entity, const SystemAddress& sys CMSGHEADER; bitStream.Write(entity->GetObjectID()); - bitStream.Write(GAME_MSG::GAME_MSG_VENDOR_OPEN_WINDOW); + bitStream.Write(eGameMessageType::VENDOR_OPEN_WINDOW); SEND_PACKET; } @@ -1276,7 +1289,7 @@ void GameMessages::SendVendorStatusUpdate(Entity* entity, const SystemAddress& s std::map vendorItems = vendor->GetInventory(); bitStream.Write(entity->GetObjectID()); - bitStream.Write(GAME_MSG::GAME_MSG_VENDOR_STATUS_UPDATE); + bitStream.Write(eGameMessageType::VENDOR_STATUS_UPDATE); bitStream.Write(bUpdateOnly); bitStream.Write(static_cast(vendorItems.size())); @@ -1297,7 +1310,7 @@ void GameMessages::SendVendorTransactionResult(Entity* entity, const SystemAddre int iResult = 0x02; // success, seems to be the only relevant one bitStream.Write(entity->GetObjectID()); - bitStream.Write(GAME_MSG::GAME_MSG_VENDOR_TRANSACTION_RESULT); + bitStream.Write(eGameMessageType::VENDOR_TRANSACTION_RESULT); bitStream.Write(iResult); SEND_PACKET; @@ -1323,7 +1336,7 @@ void GameMessages::SendRemoveItemFromInventory(Entity* entity, const SystemAddre LWOOBJID iTradeID = LWOOBJID_EMPTY; bitStream.Write(entity->GetObjectID()); - bitStream.Write(GAME_MSG::GAME_MSG_REMOVE_ITEM_FROM_INVENTORY); + bitStream.Write(eGameMessageType::REMOVE_ITEM_FROM_INVENTORY); bitStream.Write(bConfirmed); bitStream.Write(bDeleteItem); bitStream.Write(bOutSuccess); @@ -1355,7 +1368,7 @@ void GameMessages::SendConsumeClientItem(Entity* entity, bool bSuccess, LWOOBJID CMSGHEADER; bitStream.Write(entity->GetObjectID()); - bitStream.Write(GAME_MSG_CONSUME_CLIENT_ITEM); + bitStream.Write(eGameMessageType::CONSUME_CLIENT_ITEM); bitStream.Write(bSuccess); bitStream.Write(item); @@ -1368,7 +1381,7 @@ void GameMessages::SendUseItemResult(Entity* entity, LOT templateID, bool useIte CMSGHEADER; bitStream.Write(entity->GetObjectID()); - bitStream.Write(GAME_MSG_USE_ITEM_RESULT); + bitStream.Write(eGameMessageType::USE_ITEM_RESULT); bitStream.Write(templateID); bitStream.Write(useItemResult); @@ -1376,12 +1389,12 @@ void GameMessages::SendUseItemResult(Entity* entity, LOT templateID, bool useIte SEND_PACKET; } -void GameMessages::SendUseItemRequirementsResponse(LWOOBJID objectID, const SystemAddress& sysAddr, UseItemResponse itemResponse) { +void GameMessages::SendUseItemRequirementsResponse(LWOOBJID objectID, const SystemAddress& sysAddr, eUseItemResponse itemResponse) { CBITSTREAM; CMSGHEADER; bitStream.Write(objectID); - bitStream.Write(GAME_MSG::GAME_MSG_USE_ITEM_REQUIREMENTS_RESPONSE); + bitStream.Write(eGameMessageType::USE_ITEM_REQUIREMENTS_RESPONSE); bitStream.Write(itemResponse); @@ -1443,18 +1456,18 @@ void GameMessages::SendMatchResponse(Entity* entity, const SystemAddress& sysAdd CMSGHEADER; bitStream.Write(entity->GetObjectID()); - bitStream.Write(GAME_MSG::GAME_MSG_MATCH_RESPONSE); + bitStream.Write(eGameMessageType::MATCH_RESPONSE); bitStream.Write(response); SEND_PACKET; } -void GameMessages::SendMatchUpdate(Entity* entity, const SystemAddress& sysAddr, std::string data, int type) { +void GameMessages::SendMatchUpdate(Entity* entity, const SystemAddress& sysAddr, std::string data, eMatchUpdate type) { CBITSTREAM; CMSGHEADER; bitStream.Write(entity->GetObjectID()); - bitStream.Write(GAME_MSG::GAME_MSG_MATCH_UPDATE); + bitStream.Write(eGameMessageType::MATCH_UPDATE); bitStream.Write(uint32_t(data.size())); for (char character : data) { bitStream.Write(uint16_t(character)); @@ -1473,7 +1486,7 @@ void GameMessages::SendRequestActivitySummaryLeaderboardData(const LWOOBJID& obj CMSGHEADER; bitStream.Write(objectID); - bitStream.Write(GAME_MSG::GAME_MSG_REQUEST_ACTIVITY_SUMMARY_LEADERBOARD_DATA); + bitStream.Write(eGameMessageType::REQUEST_ACTIVITY_SUMMARY_LEADERBOARD_DATA); bitStream.Write(gameID != 0); if (gameID != 0) { @@ -1506,7 +1519,7 @@ void GameMessages::SendActivityPause(LWOOBJID objectId, bool pause, const System CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_ACTIVITY_PAUSE); + bitStream.Write(eGameMessageType::ACTIVITY_PAUSE); bitStream.Write(pause); if (sysAddr == UNASSIGNED_SYSTEM_ADDRESS) SEND_PACKET_BROADCAST; @@ -1518,7 +1531,7 @@ void GameMessages::SendStartActivityTime(LWOOBJID objectId, float_t startTime, c CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_START_ACTIVITY_TIME); + bitStream.Write(eGameMessageType::START_ACTIVITY_TIME); bitStream.Write(startTime); if (sysAddr == UNASSIGNED_SYSTEM_ADDRESS) SEND_PACKET_BROADCAST; @@ -1530,7 +1543,7 @@ void GameMessages::SendRequestActivityEnter(LWOOBJID objectId, const SystemAddre CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_REQUEST_ACTIVITY_ENTER); + bitStream.Write(eGameMessageType::REQUEST_ACTIVITY_ENTER); bitStream.Write(bStart); bitStream.Write(userID); @@ -1543,7 +1556,7 @@ void GameMessages::NotifyLevelRewards(LWOOBJID objectID, const SystemAddress& sy CMSGHEADER; bitStream.Write(objectID); - bitStream.Write((uint16_t)GAME_MSG::GAME_MSG_NOTIFY_LEVEL_REWARDS); + bitStream.Write((uint16_t)eGameMessageType::NOTIFY_LEVEL_REWARDS); bitStream.Write(level); bitStream.Write(sending_rewards); @@ -1564,7 +1577,7 @@ void GameMessages::SendSetShootingGalleryParams(LWOOBJID objectId, const SystemA CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_SET_SHOOTING_GALLERY_PARAMS); + bitStream.Write(eGameMessageType::SET_SHOOTING_GALLERY_PARAMS); /* bitStream.Write(cameraFOV); bitStream.Write(cooldown); @@ -1599,7 +1612,7 @@ void GameMessages::SendNotifyClientShootingGalleryScore(LWOOBJID objectId, const CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_NOTIFY_CLIENT_SHOOTING_GALLERY_SCORE); + bitStream.Write(eGameMessageType::NOTIFY_CLIENT_SHOOTING_GALLERY_SCORE); bitStream.Write(addTime); bitStream.Write(score); bitStream.Write(target); @@ -1630,7 +1643,7 @@ void GameMessages::SendActivitySummaryLeaderboardData(const LWOOBJID& objectID, CMSGHEADER; bitStream.Write(objectID); - bitStream.Write(GAME_MSG::GAME_MSG_SEND_ACTIVITY_SUMMARY_LEADERBOARD_DATA); + bitStream.Write(eGameMessageType::SEND_ACTIVITY_SUMMARY_LEADERBOARD_DATA); bitStream.Write(leaderboard->GetGameID()); bitStream.Write(leaderboard->GetInfoType()); @@ -1709,7 +1722,7 @@ void GameMessages::SendStartCelebrationEffect(Entity* entity, const SystemAddres CMSGHEADER; bitStream.Write(entity->GetObjectID()); - bitStream.Write(GAME_MSG::GAME_MSG_START_CELEBRATION_EFFECT); + bitStream.Write(eGameMessageType::START_CELEBRATION_EFFECT); bitStream.Write(0); //animation bitStream.Write0(); //No custom bg obj @@ -1740,7 +1753,7 @@ void GameMessages::SendSetRailMovement(const LWOOBJID& objectID, bool pathGoForw CMSGHEADER; bitStream.Write(objectID); - bitStream.Write(GAME_MSG::GAME_MSG_SET_RAIL_MOVEMENT); + bitStream.Write(eGameMessageType::SET_RAIL_MOVEMENT); bitStream.Write(pathGoForward); @@ -1774,7 +1787,7 @@ void GameMessages::SendStartRailMovement(const LWOOBJID& objectID, std::u16strin CMSGHEADER; bitStream.Write(objectID); - bitStream.Write(GAME_MSG::GAME_MSG_START_RAIL_MOVEMENT); + bitStream.Write(eGameMessageType::START_RAIL_MOVEMENT); bitStream.Write(damageImmune); bitStream.Write(noAggro); @@ -1834,7 +1847,7 @@ void GameMessages::SendNotifyClientObject(const LWOOBJID& objectID, std::u16stri CMSGHEADER; bitStream.Write(objectID); - bitStream.Write(GAME_MSG::GAME_MSG_NOTIFY_CLIENT_OBJECT); + bitStream.Write(eGameMessageType::NOTIFY_CLIENT_OBJECT); bitStream.Write(uint32_t(name.size())); for (auto character : name) { @@ -1863,7 +1876,7 @@ void GameMessages::SendNotifyClientZoneObject(const LWOOBJID& objectID, const st CMSGHEADER; bitStream.Write(objectID); - bitStream.Write(GAME_MSG::GAME_MSG_NOTIFY_CLIENT_ZONE_OBJECT); + bitStream.Write(eGameMessageType::NOTIFY_CLIENT_ZONE_OBJECT); bitStream.Write(uint32_t(name.size())); for (const auto& character : name) { @@ -1889,7 +1902,7 @@ void GameMessages::SendNotifyClientFailedPrecondition(LWOOBJID objectId, const S CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_NOTIFY_CLIENT_FAILED_PRECONDITION); + bitStream.Write(eGameMessageType::NOTIFY_CLIENT_FAILED_PRECONDITION); bitStream.Write(uint32_t(failedReason.size())); for (uint16_t character : failedReason) { @@ -1907,7 +1920,7 @@ void GameMessages::SendToggleGMInvis(LWOOBJID objectId, bool enabled, const Syst CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_TOGGLE_GM_INVIS); + bitStream.Write(eGameMessageType::TOGGLE_GM_INVIS); bitStream.Write(enabled); // does not matter? if (sysAddr == UNASSIGNED_SYSTEM_ADDRESS) SEND_PACKET_BROADCAST; @@ -1919,7 +1932,7 @@ void GameMessages::SendSetName(LWOOBJID objectID, std::u16string name, const Sys CMSGHEADER; bitStream.Write(objectID); - bitStream.Write(GAME_MSG::GAME_MSG_SET_NAME); + bitStream.Write(eGameMessageType::SET_NAME); bitStream.Write(name.size()); @@ -1935,7 +1948,7 @@ void GameMessages::SendBBBSaveResponse(const LWOOBJID& objectId, const LWOOBJID& CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_BBB_SAVE_RESPONSE); + bitStream.Write(eGameMessageType::BBB_SAVE_RESPONSE); bitStream.Write(localID); @@ -1952,7 +1965,7 @@ void GameMessages::SendBBBSaveResponse(const LWOOBJID& objectId, const LWOOBJID& bitStream.Write(buffer[i]); SEND_PACKET; - PacketUtils::SavePacket("GAME_MSG_BBB_SAVE_RESPONSE.bin", (char*)bitStream.GetData(), bitStream.GetNumberOfBytesUsed()); + PacketUtils::SavePacket("eGameMessageType::BBB_SAVE_RESPONSE.bin", (char*)bitStream.GetData(), bitStream.GetNumberOfBytesUsed()); } // Property @@ -1962,7 +1975,7 @@ void GameMessages::SendOpenPropertyVendor(const LWOOBJID objectId, const SystemA CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_OPEN_PROPERTY_VENDOR); + bitStream.Write(eGameMessageType::OPEN_PROPERTY_VENDOR); if (sysAddr == UNASSIGNED_SYSTEM_ADDRESS) SEND_PACKET_BROADCAST; SEND_PACKET; @@ -1973,7 +1986,7 @@ void GameMessages::SendOpenPropertyManagment(const LWOOBJID objectId, const Syst CMSGHEADER; bitStream.Write(PropertyManagementComponent::Instance()->GetParent()->GetObjectID()); - bitStream.Write(GAME_MSG::GAME_MSG_OPEN_PROPERTY_MANAGEMENT); + bitStream.Write(eGameMessageType::OPEN_PROPERTY_MANAGEMENT); if (sysAddr == UNASSIGNED_SYSTEM_ADDRESS) SEND_PACKET_BROADCAST; SEND_PACKET; @@ -1984,7 +1997,7 @@ void GameMessages::SendDownloadPropertyData(const LWOOBJID objectId, const Prope CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_DOWNLOAD_PROPERTY_DATA); + bitStream.Write(eGameMessageType::DOWNLOAD_PROPERTY_DATA); data.Serialize(bitStream); @@ -1999,7 +2012,7 @@ void GameMessages::SendPropertyRentalResponse(const LWOOBJID objectId, const LWO CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_PROPERTY_RENTAL_RESPONSE); + bitStream.Write(eGameMessageType::PROPERTY_RENTAL_RESPONSE); bitStream.Write(cloneId); bitStream.Write(code); @@ -2015,7 +2028,7 @@ void GameMessages::SendLockNodeRotation(Entity* entity, std::string nodeName) { CMSGHEADER; bitStream.Write(entity->GetObjectID()); - bitStream.Write(GAME_MSG::GAME_MSG_LOCK_NODE_ROTATION); + bitStream.Write(eGameMessageType::LOCK_NODE_ROTATION); bitStream.Write(uint32_t(nodeName.size())); for (char character : nodeName) { @@ -2030,7 +2043,7 @@ void GameMessages::SendSetBuildModeConfirmed(LWOOBJID objectId, const SystemAddr CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_SET_BUILD_MODE_CONFIRMED); + bitStream.Write(eGameMessageType::SET_BUILD_MODE_CONFIRMED); bitStream.Write(start); bitStream.Write(warnVisitors); @@ -2050,7 +2063,7 @@ void GameMessages::SendGetModelsOnProperty(LWOOBJID objectId, std::map(models.size())); @@ -2070,7 +2083,7 @@ void GameMessages::SendZonePropertyModelEquipped(LWOOBJID objectId, LWOOBJID pla CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_ZONE_PROPERTY_MODEL_EQUIPPED); + bitStream.Write(eGameMessageType::ZONE_PROPERTY_MODEL_EQUIPPED); bitStream.Write(playerId); bitStream.Write(propertyId); @@ -2085,7 +2098,7 @@ void GameMessages::SendPlaceModelResponse(LWOOBJID objectId, const SystemAddress CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_PLACE_MODEL_RESPONSE); + bitStream.Write(eGameMessageType::PLACE_MODEL_RESPONSE); bitStream.Write(position != NiPoint3::ZERO); if (position != NiPoint3::ZERO) { @@ -2117,7 +2130,7 @@ void GameMessages::SendUGCEquipPreCreateBasedOnEditMode(LWOOBJID objectId, const CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_HANDLE_UGC_EQUIP_PRE_CREATE_BASED_ON_EDIT_MODE); + bitStream.Write(eGameMessageType::HANDLE_UGC_EQUIP_PRE_CREATE_BASED_ON_EDIT_MODE); bitStream.Write(modelCount); bitStream.Write(model); @@ -2131,7 +2144,7 @@ void GameMessages::SendUGCEquipPostDeleteBasedOnEditMode(LWOOBJID objectId, cons CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_HANDLE_UGC_EQUIP_POST_DELETE_BASED_ON_EDIT_MODE); + bitStream.Write(eGameMessageType::HANDLE_UGC_EQUIP_POST_DELETE_BASED_ON_EDIT_MODE); bitStream.Write(inventoryItem); @@ -2181,7 +2194,7 @@ void GameMessages::HandleUnUseModel(RakNet::BitStream* inStream, Entity* entity, if (unknown) { CBITSTREAM; - PacketUtils::WriteHeader(bitStream, CLIENT, MSG_CLIENT_BLUEPRINT_SAVE_RESPONSE); + PacketUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::BLUEPRINT_SAVE_RESPONSE); bitStream.Write(LWOOBJID_EMPTY); //always zero so that a check on the client passes bitStream.Write(eBlueprintSaveResponseType::PlacementFailed); // Sending a non-zero error code here prevents the client from deleting its in progress build for some reason? bitStream.Write(0); @@ -2433,7 +2446,7 @@ void GameMessages::HandleBBBLoadItemRequest(RakNet::BitStream* inStream, Entity* void GameMessages::SendBlueprintLoadItemResponse(const SystemAddress& sysAddr, bool success, LWOOBJID oldItemId, LWOOBJID newItemId) { CBITSTREAM; - PacketUtils::WriteHeader(bitStream, CLIENT, MSG_CLIENT_BLUEPRINT_LOAD_RESPONSE_ITEMID); + PacketUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::BLUEPRINT_LOAD_RESPONSE_ITEMID); bitStream.Write(static_cast(success)); bitStream.Write(oldItemId); bitStream.Write(newItemId); @@ -2445,7 +2458,7 @@ void GameMessages::SendSmash(Entity* entity, float force, float ghostOpacity, LW CMSGHEADER; bitStream.Write(entity->GetObjectID()); - bitStream.Write(GAME_MSG::GAME_MSG_SMASH); + bitStream.Write(eGameMessageType::SMASH); bitStream.Write(ignoreObjectVisibility); bitStream.Write(force); @@ -2460,7 +2473,7 @@ void GameMessages::SendUnSmash(Entity* entity, LWOOBJID builderID, float duratio CMSGHEADER; bitStream.Write(entity->GetObjectID()); - bitStream.Write(GAME_MSG::GAME_MSG_UNSMASH); + bitStream.Write(eGameMessageType::UNSMASH); bitStream.Write(builderID != LWOOBJID_EMPTY); if (builderID != LWOOBJID_EMPTY) bitStream.Write(builderID); @@ -2473,8 +2486,8 @@ void GameMessages::SendUnSmash(Entity* entity, LWOOBJID builderID, float duratio void GameMessages::HandleControlBehaviors(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { AMFDeserialize reader; - std::unique_ptr amfArguments(reader.Read(inStream)); - if (amfArguments->GetValueType() != AMFValueType::AMFArray) return; + std::unique_ptr amfArguments(reader.Read(inStream)); + if (amfArguments->GetValueType() != eAmf::Array) return; uint32_t commandLength{}; inStream->Read(commandLength); @@ -2571,19 +2584,19 @@ void GameMessages::HandleBBBSaveRequest(RakNet::BitStream* inStream, Entity* ent //We runs this in async because the http library here is blocking, meaning it'll halt the thread. //But we don't want the server to go unresponsive, because then the client would disconnect. - std::async(std::launch::async, [&]() { + auto returnVal = std::async(std::launch::async, [&]() { //We need to get a new ID for our model first: ObjectIDManager::Instance()->RequestPersistentID([=](uint32_t newID) { LWOOBJID newIDL = newID; - newIDL = GeneralUtils::SetBit(newIDL, OBJECT_BIT_CHARACTER); - newIDL = GeneralUtils::SetBit(newIDL, OBJECT_BIT_PERSISTENT); + GeneralUtils::SetBit(newIDL, eObjectBits::CHARACTER); + GeneralUtils::SetBit(newIDL, eObjectBits::PERSISTENT); ObjectIDManager::Instance()->RequestPersistentID([=](uint32_t blueprintIDSmall) { blueprintIDSmall = ObjectIDManager::Instance()->GenerateRandomObjectID(); LWOOBJID blueprintID = blueprintIDSmall; - blueprintID = GeneralUtils::SetBit(blueprintID, OBJECT_BIT_CHARACTER); - blueprintID = GeneralUtils::SetBit(blueprintID, OBJECT_BIT_PERSISTENT); + GeneralUtils::SetBit(blueprintID, eObjectBits::CHARACTER); + GeneralUtils::SetBit(blueprintID, eObjectBits::PERSISTENT); //We need to get the propertyID: (stolen from Wincent's propertyManagementComp) const auto& worldId = dZoneManager::Instance()->GetZone()->GetZoneID(); @@ -2681,7 +2694,7 @@ void GameMessages::HandleBBBSaveRequest(RakNet::BitStream* inStream, Entity* ent //Tell the client their model is saved: (this causes us to actually pop out of our current state): CBITSTREAM; - PacketUtils::WriteHeader(bitStream, CLIENT, CLIENT::MSG_CLIENT_BLUEPRINT_SAVE_RESPONSE); + PacketUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::BLUEPRINT_SAVE_RESPONSE); bitStream.Write(localId); bitStream.Write(eBlueprintSaveResponseType::EverythingWorked); bitStream.Write(1); @@ -2821,7 +2834,7 @@ void GameMessages::SendPlayCinematic(LWOOBJID objectId, std::u16string pathName, CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_PLAY_CINEMATIC); + bitStream.Write(eGameMessageType::PLAY_CINEMATIC); bitStream.Write(allowGhostUpdates); bitStream.Write(bCloseMultiInteract); @@ -2860,7 +2873,7 @@ void GameMessages::SendEndCinematic(LWOOBJID objectId, std::u16string pathName, CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_END_CINEMATIC); + bitStream.Write(eGameMessageType::END_CINEMATIC); bitStream.Write(leadOut != -1); if (leadOut != -1) bitStream.Write(leadOut); @@ -2879,7 +2892,7 @@ void GameMessages::SendEndCinematic(LWOOBJID objectId, std::u16string pathName, void GameMessages::HandleCinematicUpdate(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { eCinematicEvent event; if (!inStream->ReadBit()) { - event = STARTED; + event = eCinematicEvent::STARTED; } else { inStream->Read(event); } @@ -2933,7 +2946,7 @@ void GameMessages::SendSetStunned(LWOOBJID objectId, eStateChangeType stateChang CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_SET_STUNNED); + bitStream.Write(eGameMessageType::SET_STUNNED); bitStream.Write(originator != LWOOBJID_EMPTY); if (originator != LWOOBJID_EMPTY) bitStream.Write(originator); @@ -2982,7 +2995,7 @@ void GameMessages::SendSetStunImmunity(LWOOBJID target, eStateChangeType state, CMSGHEADER; bitStream.Write(target); - bitStream.Write(GAME_MSG::GAME_MSG_SET_STUN_IMMUNITY); + bitStream.Write(eGameMessageType::SET_STUN_IMMUNITY); bitStream.Write(originator != LWOOBJID_EMPTY); if (originator != LWOOBJID_EMPTY) bitStream.Write(originator); @@ -3015,7 +3028,7 @@ void GameMessages::SendSetStatusImmunity(LWOOBJID objectId, eStateChangeType sta CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_SET_STATUS_IMMUNITY); + bitStream.Write(eGameMessageType::SET_STATUS_IMMUNITY); bitStream.Write(state); @@ -3038,7 +3051,7 @@ void GameMessages::SendOrientToAngle(LWOOBJID objectId, bool bRelativeToCurrent, CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_ORIENT_TO_ANGLE); + bitStream.Write(eGameMessageType::ORIENT_TO_ANGLE); bitStream.Write(bRelativeToCurrent); bitStream.Write(fAngle); @@ -3053,7 +3066,7 @@ void GameMessages::SendAddRunSpeedModifier(LWOOBJID objectId, LWOOBJID caster, u CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_ADD_RUN_SPEED_MODIFIER); + bitStream.Write(eGameMessageType::ADD_RUN_SPEED_MODIFIER); bitStream.Write(caster != LWOOBJID_EMPTY); if (caster != LWOOBJID_EMPTY) bitStream.Write(caster); @@ -3070,7 +3083,7 @@ void GameMessages::SendRemoveRunSpeedModifier(LWOOBJID objectId, uint32_t modifi CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_REMOVE_RUN_SPEED_MODIFIER); + bitStream.Write(eGameMessageType::REMOVE_RUN_SPEED_MODIFIER); bitStream.Write(modifier != 500); if (modifier != 500) bitStream.Write(modifier); @@ -3084,7 +3097,7 @@ void GameMessages::SendPropertyEntranceBegin(LWOOBJID objectId, const SystemAddr CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_PROPERTY_ENTRANCE_BEGIN); + bitStream.Write(eGameMessageType::PROPERTY_ENTRANCE_BEGIN); if (sysAddr == UNASSIGNED_SYSTEM_ADDRESS) SEND_PACKET_BROADCAST; SEND_PACKET; @@ -3095,7 +3108,7 @@ void GameMessages::SendPropertySelectQuery(LWOOBJID objectId, int32_t navOffset, CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_PROPERTY_SELECT_QUERY); + bitStream.Write(eGameMessageType::PROPERTY_SELECT_QUERY); bitStream.Write(navOffset); bitStream.Write(thereAreMore); @@ -3118,7 +3131,7 @@ void GameMessages::SendNotifyObject(LWOOBJID objectId, LWOOBJID objIDSender, std CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_NOTIFY_OBJECT); + bitStream.Write(eGameMessageType::NOTIFY_OBJECT); bitStream.Write(objIDSender); bitStream.Write(static_cast(name.size())); @@ -3158,7 +3171,7 @@ void GameMessages::SendTeamPickupItem(LWOOBJID objectId, LWOOBJID lootID, LWOOBJ CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_TEAM_PICKUP_ITEM); + bitStream.Write(eGameMessageType::TEAM_PICKUP_ITEM); bitStream.Write(lootID); bitStream.Write(lootOwnerID); @@ -3174,7 +3187,7 @@ void GameMessages::SendServerTradeInvite(LWOOBJID objectId, bool bNeedInvitePopU CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_SERVER_TRADE_INVITE); + bitStream.Write(eGameMessageType::SERVER_TRADE_INVITE); bitStream.Write(bNeedInvitePopUp); bitStream.Write(i64Requestor); @@ -3192,7 +3205,7 @@ void GameMessages::SendServerTradeInitialReply(LWOOBJID objectId, LWOOBJID i64In CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_SERVER_TRADE_INITIAL_REPLY); + bitStream.Write(eGameMessageType::SERVER_TRADE_INITIAL_REPLY); bitStream.Write(i64Invitee); bitStream.Write(resultType); @@ -3210,7 +3223,7 @@ void GameMessages::SendServerTradeFinalReply(LWOOBJID objectId, bool bResult, LW CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_SERVER_TRADE_FINAL_REPLY); + bitStream.Write(eGameMessageType::SERVER_TRADE_FINAL_REPLY); bitStream.Write(bResult); bitStream.Write(i64Invitee); @@ -3228,7 +3241,7 @@ void GameMessages::SendServerTradeAccept(LWOOBJID objectId, bool bFirst, const S CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_SERVER_TRADE_ACCEPT); + bitStream.Write(eGameMessageType::SERVER_TRADE_ACCEPT); bitStream.Write(bFirst); @@ -3241,7 +3254,7 @@ void GameMessages::SendServerTradeCancel(LWOOBJID objectId, const SystemAddress& CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_SERVER_TRADE_CANCEL); + bitStream.Write(eGameMessageType::SERVER_TRADE_CANCEL); if (sysAddr == UNASSIGNED_SYSTEM_ADDRESS) SEND_PACKET_BROADCAST; SEND_PACKET; @@ -3252,7 +3265,7 @@ void GameMessages::SendServerTradeUpdate(LWOOBJID objectId, uint64_t coins, cons CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_SERVER_TRADE_UPDATE); + bitStream.Write(eGameMessageType::SERVER_TRADE_UPDATE); bitStream.Write(false); bitStream.Write(coins); @@ -3425,12 +3438,12 @@ void GameMessages::HandleClientTradeUpdate(RakNet::BitStream* inStream, Entity* //Pets: -void GameMessages::SendNotifyPetTamingMinigame(LWOOBJID objectId, LWOOBJID petId, LWOOBJID playerTamingId, bool bForceTeleport, uint32_t notifyType, NiPoint3 petsDestPos, NiPoint3 telePos, NiQuaternion teleRot, const SystemAddress& sysAddr) { +void GameMessages::SendNotifyPetTamingMinigame(LWOOBJID objectId, LWOOBJID petId, LWOOBJID playerTamingId, bool bForceTeleport, ePetTamingNotifyType notifyType, NiPoint3 petsDestPos, NiPoint3 telePos, NiQuaternion teleRot, const SystemAddress& sysAddr) { CBITSTREAM; CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_NOTIFY_PET_TAMING_MINIGAME); + bitStream.Write(eGameMessageType::NOTIFY_PET_TAMING_MINIGAME); bitStream.Write(petId); bitStream.Write(playerTamingId); @@ -3452,7 +3465,7 @@ void GameMessages::SendNotifyTamingModelLoadedOnServer(LWOOBJID objectId, const CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_NOTIFY_TAMING_MODEL_LOADED_ON_SERVER); + bitStream.Write(eGameMessageType::NOTIFY_TAMING_MODEL_LOADED_ON_SERVER); if (sysAddr == UNASSIGNED_SYSTEM_ADDRESS) SEND_PACKET_BROADCAST; SEND_PACKET; @@ -3463,7 +3476,7 @@ void GameMessages::SendNotifyPetTamingPuzzleSelected(LWOOBJID objectId, std::vec CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_NOTIFY_PET_TAMING_PUZZLE_SELECTED); + bitStream.Write(eGameMessageType::NOTIFY_PET_TAMING_PUZZLE_SELECTED); bitStream.Write(static_cast(bricks.size())); for (const auto& brick : bricks) { @@ -3480,7 +3493,7 @@ void GameMessages::SendPetTamingTryBuildResult(LWOOBJID objectId, bool bSuccess, CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_PET_TAMING_TRY_BUILD_RESULT); + bitStream.Write(eGameMessageType::PET_TAMING_TRY_BUILD_RESULT); bitStream.Write(bSuccess); bitStream.Write(iNumCorrect != 0); @@ -3495,7 +3508,7 @@ void GameMessages::SendPetResponse(LWOOBJID objectId, LWOOBJID objIDPet, int32_t CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_PET_RESPONSE); + bitStream.Write(eGameMessageType::PET_RESPONSE); bitStream.Write(objIDPet); bitStream.Write(iPetCommandType); @@ -3511,7 +3524,7 @@ void GameMessages::SendAddPetToPlayer(LWOOBJID objectId, int32_t iElementalType, CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_ADD_PET_TO_PLAYER); + bitStream.Write(eGameMessageType::ADD_PET_TO_PLAYER); bitStream.Write(iElementalType); bitStream.Write(static_cast(name.size())); @@ -3531,7 +3544,7 @@ void GameMessages::SendRegisterPetID(LWOOBJID objectId, LWOOBJID objID, const Sy CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_REGISTER_PET_ID); + bitStream.Write(eGameMessageType::REGISTER_PET_ID); bitStream.Write(objID); @@ -3544,7 +3557,7 @@ void GameMessages::SendRegisterPetDBID(LWOOBJID objectId, LWOOBJID petDBID, cons CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_REGISTER_PET_DBID); + bitStream.Write(eGameMessageType::REGISTER_PET_DBID); bitStream.Write(petDBID); @@ -3557,7 +3570,7 @@ void GameMessages::SendMarkInventoryItemAsActive(LWOOBJID objectId, bool bActive CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_MARK_INVENTORY_ITEM_AS_ACTIVE); + bitStream.Write(eGameMessageType::MARK_INVENTORY_ITEM_AS_ACTIVE); bitStream.Write(bActive); @@ -3576,7 +3589,7 @@ void GameMessages::SendClientExitTamingMinigame(LWOOBJID objectId, bool bVolunta CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_CLIENT_EXIT_TAMING_MINIGAME); + bitStream.Write(eGameMessageType::CLIENT_EXIT_TAMING_MINIGAME); bitStream.Write(bVoluntaryExit); @@ -3589,7 +3602,7 @@ void GameMessages::SendShowPetActionButton(LWOOBJID objectId, int32_t buttonLabe CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_SHOW_PET_ACTION_BUTTON); + bitStream.Write(eGameMessageType::SHOW_PET_ACTION_BUTTON); bitStream.Write(buttonLabel); bitStream.Write(bShow); @@ -3603,7 +3616,7 @@ void GameMessages::SendPlayEmote(LWOOBJID objectId, int32_t emoteID, LWOOBJID ta CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_PLAY_EMOTE); + bitStream.Write(eGameMessageType::PLAY_EMOTE); bitStream.Write(emoteID); bitStream.Write(target); @@ -3617,7 +3630,7 @@ void GameMessages::SendRemoveBuff(Entity* entity, bool fromUnEquip, bool removeI CMSGHEADER; bitStream.Write(entity->GetObjectID()); - bitStream.Write(GAME_MSG::GAME_MSG_REMOVE_BUFF); + bitStream.Write(eGameMessageType::REMOVE_BUFF); bitStream.Write(false); // bFromRemoveBehavior but setting this to true makes the GM not do anything on the client? bitStream.Write(fromUnEquip); @@ -3632,7 +3645,7 @@ void GameMessages::SendBouncerActiveStatus(LWOOBJID objectId, bool bActive, cons CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_BOUNCER_ACTIVE_STATUS); + bitStream.Write(eGameMessageType::BOUNCER_ACTIVE_STATUS); bitStream.Write(bActive); @@ -3646,7 +3659,7 @@ void GameMessages::SendSetPetName(LWOOBJID objectId, std::u16string name, LWOOBJ CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_SET_PET_NAME); + bitStream.Write(eGameMessageType::SET_PET_NAME); bitStream.Write(static_cast(name.size())); for (const auto character : name) { @@ -3666,7 +3679,7 @@ void GameMessages::SendSetPetNameModerated(LWOOBJID objectId, LWOOBJID petDBID, CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_SET_PET_NAME_MODERATED); + bitStream.Write(eGameMessageType::SET_PET_NAME_MODERATED); bitStream.Write(petDBID != LWOOBJID_EMPTY); if (petDBID != LWOOBJID_EMPTY) bitStream.Write(petDBID); @@ -3683,7 +3696,7 @@ void GameMessages::SendPetNameChanged(LWOOBJID objectId, int32_t moderationStatu CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_PET_NAME_CHANGED); + bitStream.Write(eGameMessageType::PET_NAME_CHANGED); bitStream.Write(moderationStatus); @@ -3879,7 +3892,7 @@ void GameMessages::HandleMessageBoxResponse(RakNet::BitStream* inStream, Entity* auto* racingControlComponent = entity->GetComponent(); if (racingControlComponent != nullptr) { - racingControlComponent->HandleMessageBoxResponse(userEntity, GeneralUtils::UTF16ToWTF8(identifier)); + racingControlComponent->HandleMessageBoxResponse(userEntity, iButton, GeneralUtils::UTF16ToWTF8(identifier)); } for (auto* shootingGallery : EntityManager::Instance()->GetEntitiesByComponent(eReplicaComponentType::SHOOTING_GALLERY)) { @@ -3932,7 +3945,7 @@ void GameMessages::SendDisplayZoneSummary(LWOOBJID objectId, const SystemAddress CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_DISPLAY_ZONE_SUMMARY); + bitStream.Write(eGameMessageType::DISPLAY_ZONE_SUMMARY); bitStream.Write(isPropertyMap); bitStream.Write(isZoneStart); @@ -3950,7 +3963,7 @@ void GameMessages::SendNotifyNotEnoughInvSpace(LWOOBJID objectId, uint32_t freeS CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_VEHICLE_NOTIFY_FINISHED_RACE); + bitStream.Write(eGameMessageType::VEHICLE_NOTIFY_FINISHED_RACE); bitStream.Write(freeSlotsNeeded); bitStream.Write(inventoryType != 0); @@ -3965,7 +3978,7 @@ void GameMessages::SendDisplayMessageBox(LWOOBJID objectId, bool bShow, LWOOBJID CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_DISPLAY_MESSAGE_BOX); + bitStream.Write(eGameMessageType::DISPLAY_MESSAGE_BOX); bitStream.Write(bShow); bitStream.Write(callbackClient); @@ -3992,12 +4005,12 @@ void GameMessages::SendDisplayMessageBox(LWOOBJID objectId, bool bShow, LWOOBJID } void GameMessages::SendDisplayChatBubble(LWOOBJID objectId, const std::u16string& text, const SystemAddress& sysAddr) { - // GAME_MSG_DISPLAY_CHAT_BUBBLE + // eGameMessageType::DISPLAY_CHAT_BUBBLE CBITSTREAM; CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_DISPLAY_CHAT_BUBBLE); + bitStream.Write(eGameMessageType::DISPLAY_CHAT_BUBBLE); bitStream.Write(static_cast(text.size())); for (const auto character : text) { @@ -4014,7 +4027,7 @@ void GameMessages::SendChangeIdleFlags(LWOOBJID objectId, eAnimationFlags flagsO CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_CHANGE_IDLE_FLAGS); + bitStream.Write(eGameMessageType::CHANGE_IDLE_FLAGS); bitStream.Write(flagsOff != eAnimationFlags::IDLE_NONE); if (flagsOff != eAnimationFlags::IDLE_NONE) bitStream.Write(flagsOff); bitStream.Write(flagsOn != eAnimationFlags::IDLE_NONE); @@ -4028,7 +4041,7 @@ void GameMessages::SendSetMountInventoryID(Entity* entity, const LWOOBJID& objec CBITSTREAM; CMSGHEADER; bitStream.Write(entity->GetObjectID()); - bitStream.Write(GAME_MSG::GAME_MSG_SET_MOUNT_INVENTORY_ID); + bitStream.Write(eGameMessageType::SET_MOUNT_INVENTORY_ID); bitStream.Write(objectID); SEND_PACKET_BROADCAST; @@ -4141,7 +4154,7 @@ void GameMessages::HandleRequestDie(RakNet::BitStream* inStream, Entity* entity, float directionRelativeAngleXZ; float directionRelativeAngleY; float directionRelativeForce; - int32_t killType = VIOLENT; + eKillType killType = eKillType::VIOLENT; LWOOBJID killerID; LWOOBJID lootOwnerID = LWOOBJID_EMPTY; @@ -4231,7 +4244,7 @@ void GameMessages::SendUpdateReputation(const LWOOBJID objectId, const int64_t r CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_UPDATE_REPUTATION); + bitStream.Write(eGameMessageType::UPDATE_REPUTATION); bitStream.Write(reputation); @@ -4305,7 +4318,7 @@ void GameMessages::SendModuleAssemblyDBDataForClient(LWOOBJID objectId, LWOOBJID CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_MODULE_ASSEMBLY_DB_DATA_FOR_CLIENT); + bitStream.Write(eGameMessageType::MODULE_ASSEMBLY_DB_DATA_FOR_CLIENT); bitStream.Write(assemblyID); @@ -4324,7 +4337,7 @@ void GameMessages::SendNotifyVehicleOfRacingObject(LWOOBJID objectId, LWOOBJID r CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_NOTIFY_VEHICLE_OF_RACING_OBJECT); + bitStream.Write(eGameMessageType::NOTIFY_VEHICLE_OF_RACING_OBJECT); bitStream.Write(racingObjectID != LWOOBJID_EMPTY); if (racingObjectID != LWOOBJID_EMPTY) bitStream.Write(racingObjectID); @@ -4339,7 +4352,7 @@ void GameMessages::SendRacingPlayerLoaded(LWOOBJID objectId, LWOOBJID playerID, CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_RACING_PLAYER_LOADED); + bitStream.Write(eGameMessageType::RACING_PLAYER_LOADED); bitStream.Write(playerID); bitStream.Write(vehicleID); @@ -4354,7 +4367,7 @@ void GameMessages::SendVehicleUnlockInput(LWOOBJID objectId, bool bLockWheels, c CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_VEHICLE_UNLOCK_INPUT); + bitStream.Write(eGameMessageType::VEHICLE_UNLOCK_INPUT); bitStream.Write(bLockWheels); @@ -4368,7 +4381,7 @@ void GameMessages::SendVehicleSetWheelLockState(LWOOBJID objectId, bool bExtraFr CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_VEHICLE_SET_WHEEL_LOCK_STATE); + bitStream.Write(eGameMessageType::VEHICLE_SET_WHEEL_LOCK_STATE); bitStream.Write(bExtraFriction); bitStream.Write(bLocked); @@ -4383,7 +4396,7 @@ void GameMessages::SendRacingSetPlayerResetInfo(LWOOBJID objectId, int32_t curre CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_RACING_SET_PLAYER_RESET_INFO); + bitStream.Write(eGameMessageType::RACING_SET_PLAYER_RESET_INFO); bitStream.Write(currentLap); bitStream.Write(furthestResetPlane); @@ -4401,7 +4414,7 @@ void GameMessages::SendRacingResetPlayerToLastReset(LWOOBJID objectId, LWOOBJID CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_RACING_RESET_PLAYER_TO_LAST_RESET); + bitStream.Write(eGameMessageType::RACING_RESET_PLAYER_TO_LAST_RESET); bitStream.Write(playerID); @@ -4414,8 +4427,8 @@ void GameMessages::SendVehicleStopBoost(Entity* targetEntity, const SystemAddres CMSGHEADER; bitStream.Write(targetEntity->GetObjectID()); - bitStream.Write(GAME_MSG::GAME_MSG_VEHICLE_STOP_BOOST); - + bitStream.Write(eGameMessageType::VEHICLE_STOP_BOOST); + bitStream.Write(affectPassive); SEND_PACKET_BROADCAST; @@ -4426,8 +4439,8 @@ void GameMessages::SendSetResurrectRestoreValues(Entity* targetEntity, int32_t a CMSGHEADER; bitStream.Write(targetEntity->GetObjectID()); - bitStream.Write(GAME_MSG::GAME_MSG_SET_RESURRECT_RESTORE_VALUES); - + bitStream.Write(eGameMessageType::SET_RESURRECT_RESTORE_VALUES); + bitStream.Write(armorRestore != -1); if (armorRestore != -1) bitStream.Write(armorRestore); @@ -4445,7 +4458,7 @@ void GameMessages::SendNotifyRacingClient(LWOOBJID objectId, int32_t eventType, CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_NOTIFY_RACING_CLIENT); + bitStream.Write(eGameMessageType::NOTIFY_RACING_CLIENT); bitStream.Write(eventType != 0); if (eventType != 0) bitStream.Write(eventType); @@ -4471,7 +4484,7 @@ void GameMessages::SendActivityEnter(LWOOBJID objectId, const SystemAddress& sys CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_ACTIVITY_ENTER); + bitStream.Write(eGameMessageType::ACTIVITY_ENTER); if (sysAddr == UNASSIGNED_SYSTEM_ADDRESS) SEND_PACKET_BROADCAST; SEND_PACKET; @@ -4483,7 +4496,7 @@ void GameMessages::SendActivityStart(LWOOBJID objectId, const SystemAddress& sys CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_ACTIVITY_START); + bitStream.Write(eGameMessageType::ACTIVITY_START); if (sysAddr == UNASSIGNED_SYSTEM_ADDRESS) SEND_PACKET_BROADCAST; SEND_PACKET; @@ -4495,7 +4508,7 @@ void GameMessages::SendActivityExit(LWOOBJID objectId, const SystemAddress& sysA CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_ACTIVITY_EXIT); + bitStream.Write(eGameMessageType::ACTIVITY_EXIT); if (sysAddr == UNASSIGNED_SYSTEM_ADDRESS) SEND_PACKET_BROADCAST; SEND_PACKET; @@ -4507,7 +4520,7 @@ void GameMessages::SendActivityStop(LWOOBJID objectId, bool bExit, bool bUserCan CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_ACTIVITY_STOP); + bitStream.Write(eGameMessageType::ACTIVITY_STOP); bitStream.Write(bExit); bitStream.Write(bUserCancel); @@ -4522,7 +4535,7 @@ void GameMessages::SendVehicleAddPassiveBoostAction(LWOOBJID objectId, const Sys CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_VEHICLE_ADD_PASSIVE_BOOST_ACTION); + bitStream.Write(eGameMessageType::VEHICLE_ADD_PASSIVE_BOOST_ACTION); if (sysAddr == UNASSIGNED_SYSTEM_ADDRESS) SEND_PACKET_BROADCAST; SEND_PACKET; @@ -4534,7 +4547,7 @@ void GameMessages::SendVehicleRemovePassiveBoostAction(LWOOBJID objectId, const CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_VEHICLE_REMOVE_PASSIVE_BOOST_ACTION); + bitStream.Write(eGameMessageType::VEHICLE_REMOVE_PASSIVE_BOOST_ACTION); if (sysAddr == UNASSIGNED_SYSTEM_ADDRESS) SEND_PACKET_BROADCAST; SEND_PACKET; @@ -4546,7 +4559,7 @@ void GameMessages::SendVehicleNotifyFinishedRace(LWOOBJID objectId, const System CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_VEHICLE_NOTIFY_FINISHED_RACE); + bitStream.Write(eGameMessageType::VEHICLE_NOTIFY_FINISHED_RACE); if (sysAddr == UNASSIGNED_SYSTEM_ADDRESS) SEND_PACKET_BROADCAST; SEND_PACKET; @@ -4560,7 +4573,7 @@ void GameMessages::SendAddBuff(LWOOBJID& objectID, const LWOOBJID& casterID, uin CMSGHEADER; bitStream.Write(objectID); - bitStream.Write(GAME_MSG::GAME_MSG_ADD_BUFF); + bitStream.Write(eGameMessageType::ADD_BUFF); bitStream.Write(false); // Added by teammate bitStream.Write(false); // Apply on teammates @@ -4641,7 +4654,7 @@ void GameMessages::SendShowActivityCountdown(LWOOBJID objectId, bool bPlayAdditi CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_SHOW_ACTIVITY_COUNTDOWN); + bitStream.Write(eGameMessageType::SHOW_ACTIVITY_COUNTDOWN); bitStream.Write(bPlayAdditionalSound); @@ -4766,7 +4779,7 @@ void GameMessages::HandleBuyFromVendor(RakNet::BitStream* inStream, Entity* enti inv->RemoveItem(tokenId, altCurrencyCost); - inv->AddItem(item, count, eLootSourceType::LOOT_SOURCE_VENDOR); + inv->AddItem(item, count, eLootSourceType::VENDOR); } else { float buyScalar = vend->GetBuyScalar(); @@ -4786,8 +4799,8 @@ void GameMessages::HandleBuyFromVendor(RakNet::BitStream* inStream, Entity* enti inv->RemoveItem(itemComp.currencyLOT, altCurrencyCost); } - character->SetCoins(character->GetCoins() - (coinCost), eLootSourceType::LOOT_SOURCE_VENDOR); - inv->AddItem(item, count, eLootSourceType::LOOT_SOURCE_VENDOR); + character->SetCoins(character->GetCoins() - (coinCost), eLootSourceType::VENDOR); + inv->AddItem(item, count, eLootSourceType::VENDOR); } GameMessages::SendVendorTransactionResult(entity, sysAddr); @@ -4829,12 +4842,12 @@ void GameMessages::HandleSellToVendor(RakNet::BitStream* inStream, Entity* entit float sellScalar = vend->GetSellScalar(); if (Inventory::IsValidItem(itemComp.currencyLOT)) { const auto altCurrency = static_cast(itemComp.altCurrencyCost * sellScalar) * count; - inv->AddItem(itemComp.currencyLOT, std::floor(altCurrency), eLootSourceType::LOOT_SOURCE_VENDOR); // Return alt currencies like faction tokens. + inv->AddItem(itemComp.currencyLOT, std::floor(altCurrency), eLootSourceType::VENDOR); // Return alt currencies like faction tokens. } //inv->RemoveItem(count, -1, iObjID); inv->MoveItemToInventory(item, eInventoryType::VENDOR_BUYBACK, count, true, false, true); - character->SetCoins(std::floor(character->GetCoins() + (static_cast(itemComp.baseValue * sellScalar) * count)), eLootSourceType::LOOT_SOURCE_VENDOR); + character->SetCoins(std::floor(character->GetCoins() + (static_cast(itemComp.baseValue * sellScalar) * count)), eLootSourceType::VENDOR); //EntityManager::Instance()->SerializeEntity(player); // so inventory updates GameMessages::SendVendorTransactionResult(entity, sysAddr); } @@ -4893,7 +4906,7 @@ void GameMessages::HandleBuybackFromVendor(RakNet::BitStream* inStream, Entity* //inv->RemoveItem(count, -1, iObjID); inv->MoveItemToInventory(item, Inventory::FindInventoryTypeForLot(item->GetLot()), count, true, false); - character->SetCoins(character->GetCoins() - cost, eLootSourceType::LOOT_SOURCE_VENDOR); + character->SetCoins(character->GetCoins() - cost, eLootSourceType::VENDOR); //EntityManager::Instance()->SerializeEntity(player); // so inventory updates GameMessages::SendVendorTransactionResult(entity, sysAddr); } @@ -5015,7 +5028,7 @@ void GameMessages::HandleRebuildCancel(RakNet::BitStream* inStream, Entity* enti RebuildComponent* rebComp = static_cast(entity->GetComponent(eReplicaComponentType::QUICK_BUILD)); if (!rebComp) return; - rebComp->CancelRebuild(EntityManager::Instance()->GetEntity(userID), eFailReason::REASON_CANCELED_EARLY); + rebComp->CancelRebuild(EntityManager::Instance()->GetEntity(userID), eQuickBuildFailReason::CANCELED_EARLY); } void GameMessages::HandleRequestUse(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { @@ -5135,12 +5148,12 @@ void GameMessages::HandleModularBuildConvertModel(RakNet::BitStream* inStream, E item->Disassemble(TEMP_MODELS); - item->SetCount(item->GetCount() - 1, false, false, true, eLootSourceType::LOOT_SOURCE_QUICKBUILD); + item->SetCount(item->GetCount() - 1, false, false, true, eLootSourceType::QUICKBUILD); } void GameMessages::HandleSetFlag(RakNet::BitStream* inStream, Entity* entity) { bool bFlag{}; - int iFlagID{}; + int32_t iFlagID{}; inStream->Read(bFlag); inStream->Read(iFlagID); @@ -5301,7 +5314,7 @@ void GameMessages::HandlePickupCurrency(RakNet::BitStream* inStream, Entity* ent auto* ch = entity->GetCharacter(); if (entity->CanPickupCoins(currency)) { - ch->SetCoins(ch->GetCoins() + currency, eLootSourceType::LOOT_SOURCE_PICKUP); + ch->SetCoins(ch->GetCoins() + currency, eLootSourceType::PICKUP); } } @@ -5615,9 +5628,9 @@ void GameMessages::HandleModularBuildFinish(RakNet::BitStream* inStream, Entity* config.push_back(moduleAssembly); if (count == 3) { - inv->AddItem(6416, 1, eLootSourceType::LOOT_SOURCE_QUICKBUILD, eInventoryType::MODELS, config); + inv->AddItem(6416, 1, eLootSourceType::QUICKBUILD, eInventoryType::MODELS, config); } else if (count == 7) { - inv->AddItem(8092, 1, eLootSourceType::LOOT_SOURCE_QUICKBUILD, eInventoryType::MODELS, config); + inv->AddItem(8092, 1, eLootSourceType::QUICKBUILD, eInventoryType::MODELS, config); } auto* missionComponent = character->GetComponent(); @@ -5946,7 +5959,7 @@ void GameMessages::SendGetHotPropertyData(RakNet::BitStream* inStream, Entity* e // TODO This needs to be implemented when reputation is implemented for getting hot properties. /** bitStream.Write(entity->GetObjectID()); - bitStream.Write(GAME_MSG::GAME_MSG_SEND_HOT_PROPERTY_DATA); + bitStream.Write(eGameMessageType::SEND_HOT_PROPERTY_DATA); std::vector t = {25166, 25188, 25191, 25194}; bitStream.Write(4); for (uint8_t i = 0; i < 4; i++) { @@ -6140,7 +6153,7 @@ void GameMessages::SendActivateBubbleBuffFromServer(LWOOBJID objectId, const Sys CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_ACTIVATE_BUBBLE_BUFF_FROM_SERVER); + bitStream.Write(eGameMessageType::ACTIVATE_BUBBLE_BUFF_FROM_SERVER); if (sysAddr == UNASSIGNED_SYSTEM_ADDRESS) SEND_PACKET_BROADCAST; SEND_PACKET; @@ -6151,7 +6164,7 @@ void GameMessages::SendDeactivateBubbleBuffFromServer(LWOOBJID objectId, const S CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_DEACTIVATE_BUBBLE_BUFF_FROM_SERVER); + bitStream.Write(eGameMessageType::DEACTIVATE_BUBBLE_BUFF_FROM_SERVER); if (sysAddr == UNASSIGNED_SYSTEM_ADDRESS) SEND_PACKET_BROADCAST; SEND_PACKET; @@ -6169,7 +6182,7 @@ void GameMessages::SendSetNamebillboardState(const SystemAddress& sysAddr, LWOOB CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_SET_NAME_BILLBOARD_STATE); + bitStream.Write(eGameMessageType::SET_NAME_BILLBOARD_STATE); // Technically these bits would be written, however the client does not // contain a deserialize method to actually deserialize, so we are leaving it out. @@ -6187,8 +6200,20 @@ void GameMessages::SendShowBillboardInteractIcon(const SystemAddress& sysAddr, L CMSGHEADER; bitStream.Write(objectId); - bitStream.Write(GAME_MSG::GAME_MSG_SHOW_BILLBOARD_INTERACT_ICON); + bitStream.Write(eGameMessageType::SHOW_BILLBOARD_INTERACT_ICON); if (sysAddr == UNASSIGNED_SYSTEM_ADDRESS) SEND_PACKET_BROADCAST else SEND_PACKET } + +void GameMessages::HandleRequestActivityExit(RakNet::BitStream* inStream, Entity* entity) { + bool canceled = false; + inStream->Read(canceled); + if (!canceled) return; + + LWOOBJID player_id = LWOOBJID_EMPTY; + inStream->Read(player_id); + auto player = EntityManager::Instance()->GetEntity(player_id); + if (!entity || !player) return; + entity->RequestActivityExit(entity, player_id, canceled); +} diff --git a/dGame/dGameMessages/GameMessages.h b/dGame/dGameMessages/GameMessages.h index 68f4542f..7e7a8f70 100644 --- a/dGame/dGameMessages/GameMessages.h +++ b/dGame/dGameMessages/GameMessages.h @@ -8,8 +8,11 @@ #include "eMovementPlatformState.h" #include "NiPoint3.h" #include "eEndBehavior.h" +#include "eCyclingMode.h" +#include "eLootSourceType.h" +#include "Brick.h" -class AMFValue; +class AMFBaseValue; class Entity; class Item; class NiQuaternion; @@ -23,6 +26,16 @@ enum class eAnimationFlags : uint32_t; enum class eUnequippableActiveType; enum eInventoryType : uint32_t; enum class eGameMasterLevel : uint8_t; +enum class eMatchUpdate : int32_t; +enum class eKillType : uint32_t; +enum class eObjectWorldState : uint32_t; +enum class eTerminateType : uint32_t; +enum class eControlScheme : uint32_t; +enum class eStateChangeType : uint32_t; +enum class ePetTamingNotifyType : uint32_t; +enum class eUseItemResponse : uint32_t; +enum class eQuickBuildFailReason : uint32_t; +enum class eRebuildState : uint32_t; namespace GameMessages { class PropertyDataMessage; @@ -51,8 +64,7 @@ namespace GameMessages { int targetTYPE = 0 ); - void SendPlayerSetCameraCyclingMode(const LWOOBJID& objectID, const SystemAddress& sysAddr, - bool bAllowCyclingWhileDeadOnly = true, eCyclingMode cyclingMode = ALLOW_CYCLE_TEAMMATES); + void SendPlayerSetCameraCyclingMode(const LWOOBJID& objectID, const SystemAddress& sysAddr, bool bAllowCyclingWhileDeadOnly = true, eCyclingMode cyclingMode = eCyclingMode::ALLOW_CYCLE_TEAMMATES); void SendPlayNDAudioEmitter(Entity* entity, const SystemAddress& sysAddr, std::string audioGUID); @@ -66,9 +78,9 @@ namespace GameMessages { void SendGMLevelBroadcast(const LWOOBJID& objectID, eGameMasterLevel level); void SendChatModeUpdate(const LWOOBJID& objectID, eGameMasterLevel level); - void SendAddItemToInventoryClientSync(Entity* entity, const SystemAddress& sysAddr, Item* item, const LWOOBJID& objectID, bool showFlyingLoot, int itemCount, LWOOBJID subKey = LWOOBJID_EMPTY, eLootSourceType lootSourceType = eLootSourceType::LOOT_SOURCE_NONE); - void SendNotifyClientFlagChange(const LWOOBJID& objectID, int iFlagID, bool bFlag, const SystemAddress& sysAddr); - void SendChangeObjectWorldState(const LWOOBJID& objectID, int state, const SystemAddress& sysAddr); + void SendAddItemToInventoryClientSync(Entity* entity, const SystemAddress& sysAddr, Item* item, const LWOOBJID& objectID, bool showFlyingLoot, int itemCount, LWOOBJID subKey = LWOOBJID_EMPTY, eLootSourceType lootSourceType = eLootSourceType::NONE); + void SendNotifyClientFlagChange(const LWOOBJID& objectID, uint32_t iFlagID, bool bFlag, const SystemAddress& sysAddr); + void SendChangeObjectWorldState(const LWOOBJID& objectID, eObjectWorldState state, const SystemAddress& sysAddr); void SendOfferMission(const LWOOBJID& entity, const SystemAddress& sysAddr, int32_t missionID, const LWOOBJID& offererID); void SendNotifyMission(Entity* entity, const SystemAddress& sysAddr, int missionID, int missionState, bool sendingRewards); @@ -76,8 +88,8 @@ namespace GameMessages { void NotifyLevelRewards(LWOOBJID objectID, const SystemAddress& sysAddr, int level, bool sending_rewards); void SendModifyLEGOScore(Entity* entity, const SystemAddress& sysAddr, int64_t score, eLootSourceType sourceType); - void SendUIMessageServerToSingleClient(Entity* entity, const SystemAddress& sysAddr, const std::string& message, AMFValue* args); - void SendUIMessageServerToAllClients(const std::string& message, AMFValue* args); + void SendUIMessageServerToSingleClient(Entity* entity, const SystemAddress& sysAddr, const std::string& message, AMFBaseValue& args); + void SendUIMessageServerToAllClients(const std::string& message, AMFBaseValue& args); void SendPlayEmbeddedEffectOnAllClientsNearObject(Entity* entity, std::u16string effectName, const LWOOBJID& fromObjectID, float radius); void SendPlayFXEffect(Entity* entity, int32_t effectID, const std::u16string& effectType, const std::string& name, LWOOBJID secondary, float priority = 1, float scale = 1, bool serialize = true); @@ -86,8 +98,8 @@ namespace GameMessages { void SendBroadcastTextToChatbox(Entity* entity, const SystemAddress& sysAddr, const std::u16string& attrs, const std::u16string& wsText); void SendSetCurrency(Entity* entity, int64_t currency, int lootType, const LWOOBJID& sourceID, const LOT& sourceLOT, int sourceTradeID, bool overrideCurrent, eLootSourceType sourceType); - void SendRebuildNotifyState(Entity* entity, int prevState, int state, const LWOOBJID& playerID); - void SendEnableRebuild(Entity* entity, bool enable, bool fail, bool success, int failReason, float duration, const LWOOBJID& playerID); + void SendRebuildNotifyState(Entity* entity, eRebuildState prevState, eRebuildState state, const LWOOBJID& playerID); + void SendEnableRebuild(Entity* entity, bool enable, bool fail, bool success, eQuickBuildFailReason failReason, float duration, const LWOOBJID& playerID); void AddActivityOwner(Entity* entity, LWOOBJID& ownerID); void SendTerminateInteraction(const LWOOBJID& objectID, eTerminateType type, const LWOOBJID& terminator); @@ -104,7 +116,7 @@ namespace GameMessages { void SendSetNetworkScriptVar(Entity* entity, const SystemAddress& sysAddr, std::string data); void SendDropClientLoot(Entity* entity, const LWOOBJID& sourceID, LOT item, int currency, NiPoint3 spawnPos = NiPoint3::ZERO, int count = 1); - void SendSetPlayerControlScheme(Entity* entity, eControlSceme controlScheme); + void SendSetPlayerControlScheme(Entity* entity, eControlScheme controlScheme); void SendPlayerReachedRespawnCheckpoint(Entity* entity, const NiPoint3& position, const NiQuaternion& rotation); void SendAddSkill(Entity* entity, TSkillID skillID, int slotID); @@ -123,7 +135,7 @@ namespace GameMessages { void SendMoveInventoryBatch(Entity* entity, uint32_t stackCount, int srcInv, int dstInv, const LWOOBJID& iObjID); void SendMatchResponse(Entity* entity, const SystemAddress& sysAddr, int response); - void SendMatchUpdate(Entity* entity, const SystemAddress& sysAddr, std::string data, int type); + void SendMatchUpdate(Entity* entity, const SystemAddress& sysAddr, std::string data, eMatchUpdate type); void HandleUnUseModel(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); void SendStartCelebrationEffect(Entity* entity, const SystemAddress& sysAddr, int celebrationID); @@ -350,7 +362,7 @@ namespace GameMessages { void HandleClientTradeUpdate(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr); //Pets: - void SendNotifyPetTamingMinigame(LWOOBJID objectId, LWOOBJID petId, LWOOBJID playerTamingId, bool bForceTeleport, uint32_t notifyType, NiPoint3 petsDestPos, NiPoint3 telePos, NiQuaternion teleRot, const SystemAddress& sysAddr); + void SendNotifyPetTamingMinigame(LWOOBJID objectId, LWOOBJID petId, LWOOBJID playerTamingId, bool bForceTeleport, ePetTamingNotifyType notifyType, NiPoint3 petsDestPos, NiPoint3 telePos, NiQuaternion teleRot, const SystemAddress& sysAddr); void SendNotifyPetTamingPuzzleSelected(LWOOBJID objectId, std::vector& bricks, const SystemAddress& sysAddr); @@ -520,7 +532,7 @@ namespace GameMessages { void SendActivityPause(LWOOBJID objectId, bool pause = false, const SystemAddress& sysAddr = UNASSIGNED_SYSTEM_ADDRESS); void SendStartActivityTime(LWOOBJID objectId, float_t startTime, const SystemAddress& sysAddr = UNASSIGNED_SYSTEM_ADDRESS); void SendRequestActivityEnter(LWOOBJID objectId, const SystemAddress& sysAddr, bool bStart, LWOOBJID userID); - void SendUseItemRequirementsResponse(LWOOBJID objectID, const SystemAddress& sysAddr, UseItemResponse itemResponse); + void SendUseItemRequirementsResponse(LWOOBJID objectID, const SystemAddress& sysAddr, eUseItemResponse itemResponse); // SG: @@ -636,6 +648,7 @@ namespace GameMessages { void SendDeactivateBubbleBuffFromServer(LWOOBJID objectId, const SystemAddress& sysAddr); void HandleZoneSummaryDismissed(RakNet::BitStream* inStream, Entity* entity); + void HandleRequestActivityExit(RakNet::BitStream* inStream, Entity* entity); }; #endif // GAMEMESSAGES_H diff --git a/dGame/dGameMessages/RequestServerProjectileImpact.h b/dGame/dGameMessages/RequestServerProjectileImpact.h index 01426361..090d8274 100644 --- a/dGame/dGameMessages/RequestServerProjectileImpact.h +++ b/dGame/dGameMessages/RequestServerProjectileImpact.h @@ -2,13 +2,11 @@ #define __REQUESTSERVERPROJECTILEIMPACT__H__ #include "dCommonVars.h" -#include "dMessageIdentifiers.h" +#include "eGameMessageType.h" /* Notifying the server that a locally owned projectile impacted. Sent to the caster of the projectile should always be the local char. */ class RequestServerProjectileImpact { - static const GAME_MSG MsgID = GAME_MSG_REQUEST_SERVER_PROJECTILE_IMPACT; - public: RequestServerProjectileImpact() { i64LocalID = LWOOBJID_EMPTY; @@ -29,7 +27,7 @@ public: } void Serialize(RakNet::BitStream* stream) { - stream->Write(MsgID); + stream->Write(eGameMessageType::REQUEST_SERVER_PROJECTILE_IMPACT); stream->Write(i64LocalID != LWOOBJID_EMPTY); if (i64LocalID != LWOOBJID_EMPTY) stream->Write(i64LocalID); diff --git a/dGame/dGameMessages/StartSkill.h b/dGame/dGameMessages/StartSkill.h index af82a9b4..40bc210f 100644 --- a/dGame/dGameMessages/StartSkill.h +++ b/dGame/dGameMessages/StartSkill.h @@ -2,16 +2,14 @@ #define __STARTSKILL__H__ #include "dCommonVars.h" -#include "dMessageIdentifiers.h" #include "NiPoint3.h" #include "NiQuaternion.h" +#include "eGameMessageType.h" /** * Same as sync skill but with different network options. An echo down to other clients that need to play the skill. */ class StartSkill { - static const GAME_MSG MsgID = GAME_MSG_START_SKILL; - public: StartSkill() { bUsedMouse = false; @@ -46,7 +44,7 @@ public: } void Serialize(RakNet::BitStream* stream) { - stream->Write(MsgID); + stream->Write(eGameMessageType::START_SKILL); stream->Write(bUsedMouse); diff --git a/dGame/dGameMessages/SyncSkill.h b/dGame/dGameMessages/SyncSkill.h index 72a88839..6485199e 100644 --- a/dGame/dGameMessages/SyncSkill.h +++ b/dGame/dGameMessages/SyncSkill.h @@ -5,11 +5,10 @@ #include #include "BitStream.h" +#include "eGameMessageType.h" /* Message to synchronize a skill cast */ class SyncSkill { - static const GAME_MSG MsgID = GAME_MSG_SYNC_SKILL; - public: SyncSkill() { bDone = false; @@ -30,7 +29,7 @@ public: } void Serialize(RakNet::BitStream* stream) { - stream->Write(MsgID); + stream->Write(eGameMessageType::SYNC_SKILL); stream->Write(bDone); uint32_t sBitStreamLength = sBitStream.length(); diff --git a/dGame/dInventory/Inventory.cpp b/dGame/dInventory/Inventory.cpp index d752f87d..3d2c82ae 100644 --- a/dGame/dInventory/Inventory.cpp +++ b/dGame/dInventory/Inventory.cpp @@ -244,9 +244,9 @@ eInventoryType Inventory::FindInventoryTypeForLot(const LOT lot) { return PROPERTY_DEEDS; case eItemType::MODEL: - case eItemType::VEHICLE: + case eItemType::PET_INVENTORY_ITEM: case eItemType::LOOT_MODEL: - case eItemType::LUP_MODEL: + case eItemType::VEHICLE: case eItemType::MOUNT: return MODELS; @@ -263,9 +263,8 @@ eInventoryType Inventory::FindInventoryTypeForLot(const LOT lot) { case eItemType::CHEST: case eItemType::EGG: case eItemType::PET_FOOD: - case eItemType::PET_INVENTORY_ITEM: case eItemType::PACKAGE: - + case eItemType::LUP_MODEL: return ITEMS; case eItemType::QUEST_OBJECT: diff --git a/dGame/dInventory/Item.cpp b/dGame/dInventory/Item.cpp index acaecbf7..83ac8869 100644 --- a/dGame/dInventory/Item.cpp +++ b/dGame/dInventory/Item.cpp @@ -16,7 +16,9 @@ #include "AssetManager.h" #include "InventoryComponent.h" #include "Loot.h" +#include "eObjectBits.h" #include "eReplicaComponentType.h" +#include "eUseItemResponse.h" #include "CDBrickIDTableTable.h" #include "CDObjectSkillsTable.h" @@ -77,13 +79,13 @@ Item::Item( LWOOBJID id = ObjectIDManager::GenerateRandomObjectID(); - id = GeneralUtils::SetBit(id, OBJECT_BIT_CHARACTER); - id = GeneralUtils::SetBit(id, OBJECT_BIT_PERSISTENT); + GeneralUtils::SetBit(id, eObjectBits::CHARACTER); + GeneralUtils::SetBit(id, eObjectBits::PERSISTENT); const auto type = static_cast(info->itemType); if (type == eItemType::MOUNT) { - id = GeneralUtils::SetBit(id, OBJECT_BIT_CLIENT); + GeneralUtils::SetBit(id, eObjectBits::CLIENT); } this->id = id; @@ -329,7 +331,7 @@ void Item::UseNonEquip(Item* item) { } } if (playerInventoryComponent->HasSpaceForLoot(rolledLoot)) { - LootGenerator::Instance().GiveLoot(playerInventoryComponent->GetParent(), rolledLoot, eLootSourceType::LOOT_SOURCE_CONSUMPTION); + LootGenerator::Instance().GiveLoot(playerInventoryComponent->GetParent(), rolledLoot, eLootSourceType::CONSUMPTION); item->SetCount(item->GetCount() - 1); } else { success = false; @@ -338,7 +340,7 @@ void Item::UseNonEquip(Item* item) { GameMessages::SendUseItemRequirementsResponse( playerInventoryComponent->GetParent()->GetObjectID(), playerInventoryComponent->GetParent()->GetSystemAddress(), - UseItemResponse::FailedPrecondition + eUseItemResponse::FailedPrecondition ); success = false; } @@ -378,7 +380,7 @@ void Item::Disassemble(const eInventoryType inventoryType) { } for (const auto mod : modArray) { - inventory->GetComponent()->AddItem(mod, 1, eLootSourceType::LOOT_SOURCE_DELETION, inventoryType); + inventory->GetComponent()->AddItem(mod, 1, eLootSourceType::DELETION, inventoryType); } } } @@ -390,19 +392,22 @@ void Item::DisassembleModel() { const auto componentId = table->GetByIDAndType(GetLot(), eReplicaComponentType::RENDER); auto query = CDClientDatabase::CreatePreppedStmt( - "SELECT render_asset FROM RenderComponent WHERE id = ?;"); + "SELECT render_asset, LXFMLFolder FROM RenderComponent WHERE id = ?;"); query.bind(1, (int)componentId); auto result = query.execQuery(); - if (result.eof()) { + if (result.eof() || result.fieldIsNull(0)) { return; } - std::string renderAsset = result.fieldIsNull(0) ? "" : std::string(result.getStringField(0)); - std::vector renderAssetSplit = GeneralUtils::SplitString(renderAsset, '\\'); + std::string renderAsset = std::string(result.getStringField(0)); + std::string lxfmlFolderName = std::string(result.getStringField(1)); - std::string lxfmlPath = "BrickModels/" + GeneralUtils::SplitString(renderAssetSplit.back(), '.').at(0) + ".lxfml"; + std::vector renderAssetSplit = GeneralUtils::SplitString(renderAsset, '\\'); + if (renderAssetSplit.size() == 0) return; + + std::string lxfmlPath = "BrickModels/" + lxfmlFolderName + "/" + GeneralUtils::SplitString(renderAssetSplit.back(), '.').at(0) + ".lxfml"; auto buffer = Game::assetManager->GetFileAsBuffer(lxfmlPath.c_str()); if (!buffer.m_Success) { @@ -473,7 +478,7 @@ void Item::DisassembleModel() { continue; } - GetInventory()->GetComponent()->AddItem(brickID[0].NDObjectID, 1, eLootSourceType::LOOT_SOURCE_DELETION); + GetInventory()->GetComponent()->AddItem(brickID[0].NDObjectID, 1, eLootSourceType::DELETION); } } diff --git a/dGame/dInventory/Item.h b/dGame/dInventory/Item.h index 6993a0ba..be2359ef 100644 --- a/dGame/dInventory/Item.h +++ b/dGame/dInventory/Item.h @@ -7,6 +7,7 @@ #include "dLogger.h" #include "Preconditions.h" #include "eInventoryType.h" +#include "eLootSourceType.h" /** * An item that can be stored in an inventory and optionally consumed or equipped @@ -38,7 +39,7 @@ public: const std::vector& config, LWOOBJID parent, LWOOBJID subKey, - eLootSourceType lootSourceType = eLootSourceType::LOOT_SOURCE_NONE + eLootSourceType lootSourceType = eLootSourceType::NONE ); /** @@ -65,7 +66,7 @@ public: bool isModMoveAndEquip = false, LWOOBJID subKey = LWOOBJID_EMPTY, bool bound = false, - eLootSourceType lootSourceType = eLootSourceType::LOOT_SOURCE_NONE + eLootSourceType lootSourceType = eLootSourceType::NONE ); ~Item(); @@ -89,7 +90,7 @@ public: * @param disassemble if items were removed, this returns all the sub parts of the item individually if it had assembly part lots * @param showFlyingLoot shows flying loot to the client, if not silent */ - void SetCount(uint32_t value, bool silent = false, bool disassemble = true, bool showFlyingLoot = true, eLootSourceType lootSourceType = eLootSourceType::LOOT_SOURCE_NONE); + void SetCount(uint32_t value, bool silent = false, bool disassemble = true, bool showFlyingLoot = true, eLootSourceType lootSourceType = eLootSourceType::NONE); /** * Returns the number of items this item represents (e.g. for stacks) diff --git a/dGame/dMission/Mission.cpp b/dGame/dMission/Mission.cpp index 9cfdaaa7..32a930e4 100644 --- a/dGame/dMission/Mission.cpp +++ b/dGame/dMission/Mission.cpp @@ -388,7 +388,7 @@ void Mission::Catchup() { } if (type == eMissionTaskType::PLAYER_FLAG) { - for (auto target : task->GetAllTargets()) { + for (int32_t target : task->GetAllTargets()) { const auto flag = GetUser()->GetLastUsedChar()->GetPlayerFlag(target); if (!flag) { @@ -442,7 +442,7 @@ void Mission::YieldRewards() { int32_t coinsToSend = 0; if (info->LegoScore > 0) { - eLootSourceType lootSource = info->isMission ? eLootSourceType::LOOT_SOURCE_MISSION : eLootSourceType::LOOT_SOURCE_ACHIEVEMENT; + eLootSourceType lootSource = info->isMission ? eLootSourceType::MISSION : eLootSourceType::ACHIEVEMENT; if (levelComponent->GetLevel() >= dZoneManager::Instance()->GetWorldConfig()->levelCap) { // Since the character is at the level cap we reward them with coins instead of UScore. coinsToSend += info->LegoScore * dZoneManager::Instance()->GetWorldConfig()->levelCapCurrencyConversion; @@ -475,11 +475,11 @@ void Mission::YieldRewards() { count = 0; } - inventoryComponent->AddItem(pair.first, count, IsMission() ? eLootSourceType::LOOT_SOURCE_MISSION : eLootSourceType::LOOT_SOURCE_ACHIEVEMENT); + inventoryComponent->AddItem(pair.first, count, IsMission() ? eLootSourceType::MISSION : eLootSourceType::ACHIEVEMENT); } if (info->reward_currency_repeatable > 0 || coinsToSend > 0) { - eLootSourceType lootSource = info->isMission ? eLootSourceType::LOOT_SOURCE_MISSION : eLootSourceType::LOOT_SOURCE_ACHIEVEMENT; + eLootSourceType lootSource = info->isMission ? eLootSourceType::MISSION : eLootSourceType::ACHIEVEMENT; character->SetCoins(character->GetCoins() + info->reward_currency_repeatable + coinsToSend, lootSource); } @@ -508,11 +508,11 @@ void Mission::YieldRewards() { count = 0; } - inventoryComponent->AddItem(pair.first, count, IsMission() ? eLootSourceType::LOOT_SOURCE_MISSION : eLootSourceType::LOOT_SOURCE_ACHIEVEMENT); + inventoryComponent->AddItem(pair.first, count, IsMission() ? eLootSourceType::MISSION : eLootSourceType::ACHIEVEMENT); } if (info->reward_currency > 0 || coinsToSend > 0) { - eLootSourceType lootSource = info->isMission ? eLootSourceType::LOOT_SOURCE_MISSION : eLootSourceType::LOOT_SOURCE_ACHIEVEMENT; + eLootSourceType lootSource = info->isMission ? eLootSourceType::MISSION : eLootSourceType::ACHIEVEMENT; character->SetCoins(character->GetCoins() + info->reward_currency + coinsToSend, lootSource); } diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/Action.cpp b/dGame/dPropertyBehaviors/ControlBehaviorMessages/Action.cpp index 7da286b0..eabe76b7 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/Action.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/Action.cpp @@ -12,19 +12,19 @@ Action::Action(AMFArrayValue* arguments) { valueParameterName = ""; valueParameterString = ""; valueParameterDouble = 0.0; - for (auto& typeValueMap : arguments->GetAssociativeMap()) { + for (auto& typeValueMap : arguments->GetAssociative()) { if (typeValueMap.first == "Type") { - if (typeValueMap.second->GetValueType() != AMFValueType::AMFString) continue; - type = static_cast(typeValueMap.second)->GetStringValue(); + if (typeValueMap.second->GetValueType() != eAmf::String) continue; + type = static_cast(typeValueMap.second)->GetValue(); } else { valueParameterName = typeValueMap.first; // Message is the only known string parameter if (valueParameterName == "Message") { - if (typeValueMap.second->GetValueType() != AMFValueType::AMFString) continue; - valueParameterString = static_cast(typeValueMap.second)->GetStringValue(); + if (typeValueMap.second->GetValueType() != eAmf::String) continue; + valueParameterString = static_cast(typeValueMap.second)->GetValue(); } else { - if (typeValueMap.second->GetValueType() != AMFValueType::AMFDouble) continue; - valueParameterDouble = static_cast(typeValueMap.second)->GetDoubleValue(); + if (typeValueMap.second->GetValueType() != eAmf::Double) continue; + valueParameterDouble = static_cast(typeValueMap.second)->GetValue(); } } } diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/ActionContext.cpp b/dGame/dPropertyBehaviors/ControlBehaviorMessages/ActionContext.cpp index 480eef45..c2ba2eeb 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/ActionContext.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/ActionContext.cpp @@ -2,7 +2,7 @@ #include -#include "AMFFormat.h" +#include "Amf3.h" ActionContext::ActionContext() { stripId = 0; @@ -17,15 +17,15 @@ ActionContext::ActionContext(AMFArrayValue* arguments, std::string customStateKe } BehaviorState ActionContext::GetBehaviorStateFromArgument(AMFArrayValue* arguments, const std::string& key) { - auto* stateIDValue = arguments->FindValue(key); + auto* stateIDValue = arguments->Get(key); if (!stateIDValue) throw std::invalid_argument("Unable to find behavior state from argument \"" + key + "\""); - return static_cast(stateIDValue->GetDoubleValue()); + return static_cast(stateIDValue->GetValue()); } StripId ActionContext::GetStripIdFromArgument(AMFArrayValue* arguments, const std::string& key) { - auto* stripIdValue = arguments->FindValue(key); + auto* stripIdValue = arguments->Get(key); if (!stripIdValue) throw std::invalid_argument("Unable to find strip ID from argument \"" + key + "\""); - return static_cast(stripIdValue->GetDoubleValue()); + return static_cast(stripIdValue->GetValue()); } diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddActionMessage.cpp b/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddActionMessage.cpp index 4fc7f82b..98672909 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddActionMessage.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddActionMessage.cpp @@ -4,7 +4,7 @@ AddActionMessage::AddActionMessage(AMFArrayValue* arguments) : BehaviorMessageBa actionContext = ActionContext(arguments); actionIndex = GetActionIndexFromArgument(arguments); - auto* actionValue = arguments->FindValue("action"); + auto* actionValue = arguments->GetArray("action"); if (!actionValue) return; action = Action(actionValue); diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddMessage.cpp b/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddMessage.cpp index 4f2123b4..badee2c2 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddMessage.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddMessage.cpp @@ -2,10 +2,10 @@ AddMessage::AddMessage(AMFArrayValue* arguments) : BehaviorMessageBase(arguments) { behaviorIndex = 0; - auto* behaviorIndexValue = arguments->FindValue("BehaviorIndex"); + auto* behaviorIndexValue = arguments->Get("BehaviorIndex"); if (!behaviorIndexValue) return; - behaviorIndex = static_cast(behaviorIndexValue->GetDoubleValue()); + behaviorIndex = static_cast(behaviorIndexValue->GetValue()); Game::logger->LogDebug("AddMessage", "behaviorId %i index %i", behaviorId, behaviorIndex); } diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddStripMessage.cpp b/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddStripMessage.cpp index c4729c57..261b3462 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddStripMessage.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/AddStripMessage.cpp @@ -4,17 +4,16 @@ AddStripMessage::AddStripMessage(AMFArrayValue* arguments) : BehaviorMessageBase(arguments) { actionContext = ActionContext(arguments); - position = StripUiPosition(arguments); - auto* strip = arguments->FindValue("strip"); + auto* strip = arguments->GetArray("strip"); if (!strip) return; - auto* actions = strip->FindValue("actions"); + auto* actions = strip->GetArray("actions"); if (!actions) return; - for (uint32_t actionNumber = 0; actionNumber < actions->GetDenseValueSize(); actionNumber++) { - auto* actionValue = actions->GetValueAt(actionNumber); + for (uint32_t actionNumber = 0; actionNumber < actions->GetDense().size(); actionNumber++) { + auto* actionValue = actions->GetArray(actionNumber); if (!actionValue) continue; actionsToAdd.push_back(Action(actionValue)); diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/BehaviorMessageBase.cpp b/dGame/dPropertyBehaviors/ControlBehaviorMessages/BehaviorMessageBase.cpp index b3d98d51..3286504a 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/BehaviorMessageBase.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/BehaviorMessageBase.cpp @@ -1,6 +1,6 @@ #include "BehaviorMessageBase.h" -#include "AMFFormat.h" +#include "Amf3.h" #include "BehaviorStates.h" #include "dCommonVars.h" @@ -11,12 +11,12 @@ BehaviorMessageBase::BehaviorMessageBase(AMFArrayValue* arguments) { int32_t BehaviorMessageBase::GetBehaviorIdFromArgument(AMFArrayValue* arguments) { const auto* key = "BehaviorID"; - auto* behaviorIDValue = arguments->FindValue(key); + auto* behaviorIDValue = arguments->Get(key); int32_t behaviorID = -1; - if (behaviorIDValue) { - behaviorID = std::stoul(behaviorIDValue->GetStringValue()); - } else if (!arguments->FindValue(key)) { + if (behaviorIDValue && behaviorIDValue->GetValueType() == eAmf::String) { + behaviorID = std::stoul(behaviorIDValue->GetValue()); + } else if (arguments->Get(key)->GetValueType() != eAmf::Undefined) { throw std::invalid_argument("Unable to find behavior ID"); } @@ -24,10 +24,10 @@ int32_t BehaviorMessageBase::GetBehaviorIdFromArgument(AMFArrayValue* arguments) } uint32_t BehaviorMessageBase::GetActionIndexFromArgument(AMFArrayValue* arguments, const std::string& keyName) { - auto* actionIndexAmf = arguments->FindValue(keyName); + auto* actionIndexAmf = arguments->Get(keyName); if (!actionIndexAmf) { throw std::invalid_argument("Unable to find actionIndex"); } - return static_cast(actionIndexAmf->GetDoubleValue()); + return static_cast(actionIndexAmf->GetValue()); } diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/BehaviorMessageBase.h b/dGame/dPropertyBehaviors/ControlBehaviorMessages/BehaviorMessageBase.h index 13b00a35..8771286c 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/BehaviorMessageBase.h +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/BehaviorMessageBase.h @@ -4,7 +4,7 @@ #include #include -#include "AMFFormat.h" +#include "Amf3.h" #include "dCommonVars.h" #include "Game.h" diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/MoveToInventoryMessage.cpp b/dGame/dPropertyBehaviors/ControlBehaviorMessages/MoveToInventoryMessage.cpp index 92700076..5b61ee32 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/MoveToInventoryMessage.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/MoveToInventoryMessage.cpp @@ -1,9 +1,9 @@ #include "MoveToInventoryMessage.h" MoveToInventoryMessage::MoveToInventoryMessage(AMFArrayValue* arguments) : BehaviorMessageBase(arguments) { - auto* behaviorIndexValue = arguments->FindValue("BehaviorIndex"); + auto* behaviorIndexValue = arguments->Get("BehaviorIndex"); if (!behaviorIndexValue) return; - behaviorIndex = static_cast(behaviorIndexValue->GetDoubleValue()); + behaviorIndex = static_cast(behaviorIndexValue->GetValue()); Game::logger->LogDebug("MoveToInventoryMessage", "behaviorId %i behaviorIndex %i", behaviorId, behaviorIndex); } diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/RenameMessage.cpp b/dGame/dPropertyBehaviors/ControlBehaviorMessages/RenameMessage.cpp index 0ea3b6d6..a1c2abbc 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/RenameMessage.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/RenameMessage.cpp @@ -1,9 +1,9 @@ #include "RenameMessage.h" RenameMessage::RenameMessage(AMFArrayValue* arguments) : BehaviorMessageBase(arguments) { - auto* nameAmf = arguments->FindValue("Name"); + auto* nameAmf = arguments->Get("Name"); if (!nameAmf) return; - name = nameAmf->GetStringValue(); + name = nameAmf->GetValue(); Game::logger->LogDebug("RenameMessage", "behaviorId %i n %s", behaviorId, name.c_str()); } diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/StripUiPosition.cpp b/dGame/dPropertyBehaviors/ControlBehaviorMessages/StripUiPosition.cpp index 4ddccc55..de612b45 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/StripUiPosition.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/StripUiPosition.cpp @@ -1,6 +1,6 @@ #include "StripUiPosition.h" -#include "AMFFormat.h" +#include "Amf3.h" StripUiPosition::StripUiPosition() { xPosition = 0.0; @@ -10,13 +10,13 @@ StripUiPosition::StripUiPosition() { StripUiPosition::StripUiPosition(AMFArrayValue* arguments, std::string uiKeyName) { xPosition = 0.0; yPosition = 0.0; - auto* uiArray = arguments->FindValue(uiKeyName); + auto* uiArray = arguments->GetArray(uiKeyName); if (!uiArray) return; - auto* xPositionValue = uiArray->FindValue("x"); - auto* yPositionValue = uiArray->FindValue("y"); + auto* xPositionValue = uiArray->Get("x"); + auto* yPositionValue = uiArray->Get("y"); if (!xPositionValue || !yPositionValue) return; - yPosition = yPositionValue->GetDoubleValue(); - xPosition = xPositionValue->GetDoubleValue(); + yPosition = yPositionValue->GetValue(); + xPosition = xPositionValue->GetValue(); } diff --git a/dGame/dPropertyBehaviors/ControlBehaviorMessages/UpdateActionMessage.cpp b/dGame/dPropertyBehaviors/ControlBehaviorMessages/UpdateActionMessage.cpp index 53e2d570..23a0050d 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviorMessages/UpdateActionMessage.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviorMessages/UpdateActionMessage.cpp @@ -5,7 +5,7 @@ UpdateActionMessage::UpdateActionMessage(AMFArrayValue* arguments) : BehaviorMessageBase(arguments) { actionContext = ActionContext(arguments); - auto* actionValue = arguments->FindValue("action"); + auto* actionValue = arguments->GetArray("action"); if (!actionValue) return; action = Action(actionValue); diff --git a/dGame/dPropertyBehaviors/ControlBehaviors.cpp b/dGame/dPropertyBehaviors/ControlBehaviors.cpp index dfb22b59..d8a062ca 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviors.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviors.cpp @@ -1,6 +1,6 @@ #include "ControlBehaviors.h" -#include "AMFFormat.h" +#include "Amf3.h" #include "Entity.h" #include "Game.h" #include "GameMessages.h" @@ -43,11 +43,11 @@ void ControlBehaviors::RequestUpdatedID(int32_t behaviorID, ModelComponent* mode // AMFArrayValue args; // AMFStringValue* behaviorIDString = new AMFStringValue(); - // behaviorIDString->SetStringValue(std::to_string(persistentId)); + // behaviorIDString->SetValue(std::to_string(persistentId)); // args.InsertValue("behaviorID", behaviorIDString); // AMFStringValue* objectIDAsString = new AMFStringValue(); - // objectIDAsString->SetStringValue(std::to_string(modelComponent->GetParent()->GetObjectID())); + // objectIDAsString->SetValue(std::to_string(modelComponent->GetParent()->GetObjectID())); // args.InsertValue("objectID", objectIDAsString); // GameMessages::SendUIMessageServerToSingleClient(modelOwner, sysAddr, "UpdateBehaviorID", &args); @@ -63,8 +63,6 @@ void ControlBehaviors::SendBehaviorListToClient(Entity* modelEntity, const Syste AMFArrayValue behaviorsToSerialize; - AMFArrayValue* behaviors = new AMFArrayValue(); // Empty for now - /** * The behaviors AMFArray will have up to 5 elements in the dense portion. * Each element in the dense portion will be made up of another AMFArray @@ -75,20 +73,17 @@ void ControlBehaviors::SendBehaviorListToClient(Entity* modelEntity, const Syste * "name": The name of the behavior formatted as an AMFString */ - behaviorsToSerialize.InsertValue("behaviors", behaviors); + behaviorsToSerialize.Insert("behaviors"); + behaviorsToSerialize.Insert("objectID", std::to_string(modelComponent->GetParent()->GetObjectID())); - AMFStringValue* amfStringValueForObjectID = new AMFStringValue(); - amfStringValueForObjectID->SetStringValue(std::to_string(modelComponent->GetParent()->GetObjectID())); - - behaviorsToSerialize.InsertValue("objectID", amfStringValueForObjectID); - GameMessages::SendUIMessageServerToSingleClient(modelOwner, sysAddr, "UpdateBehaviorList", &behaviorsToSerialize); + GameMessages::SendUIMessageServerToSingleClient(modelOwner, sysAddr, "UpdateBehaviorList", behaviorsToSerialize); } void ControlBehaviors::ModelTypeChanged(AMFArrayValue* arguments, ModelComponent* ModelComponent) { - auto* modelTypeAmf = arguments->FindValue("ModelType"); + auto* modelTypeAmf = arguments->Get("ModelType"); if (!modelTypeAmf) return; - uint32_t modelType = static_cast(modelTypeAmf->GetDoubleValue()); + uint32_t modelType = static_cast(modelTypeAmf->GetValue()); //TODO Update the model type here } @@ -179,7 +174,7 @@ void ControlBehaviors::SendBehaviorBlocksToClient(ModelComponent* modelComponent // AMFArrayValue* state = new AMFArrayValue(); // AMFDoubleValue* stateAsDouble = new AMFDoubleValue(); - // stateAsDouble->SetDoubleValue(it->first); + // stateAsDouble->SetValue(it->first); // state->InsertValue("id", stateAsDouble); // AMFArrayValue* strips = new AMFArrayValue(); @@ -189,16 +184,16 @@ void ControlBehaviors::SendBehaviorBlocksToClient(ModelComponent* modelComponent // AMFArrayValue* thisStrip = new AMFArrayValue(); // AMFDoubleValue* stripID = new AMFDoubleValue(); - // stripID->SetDoubleValue(strip->first); + // stripID->SetValue(strip->first); // thisStrip->InsertValue("id", stripID); // AMFArrayValue* uiArray = new AMFArrayValue(); // AMFDoubleValue* yPosition = new AMFDoubleValue(); - // yPosition->SetDoubleValue(strip->second->GetYPosition()); + // yPosition->SetValue(strip->second->GetYPosition()); // uiArray->InsertValue("y", yPosition); // AMFDoubleValue* xPosition = new AMFDoubleValue(); - // xPosition->SetDoubleValue(strip->second->GetXPosition()); + // xPosition->SetValue(strip->second->GetXPosition()); // uiArray->InsertValue("x", xPosition); // thisStrip->InsertValue("ui", uiArray); @@ -211,19 +206,19 @@ void ControlBehaviors::SendBehaviorBlocksToClient(ModelComponent* modelComponent // AMFArrayValue* thisAction = new AMFArrayValue(); // AMFStringValue* actionName = new AMFStringValue(); - // actionName->SetStringValue(behaviorAction->actionName); + // actionName->SetValue(behaviorAction->actionName); // thisAction->InsertValue("Type", actionName); // if (behaviorAction->parameterValueString != "") // { // AMFStringValue* valueAsString = new AMFStringValue(); - // valueAsString->SetStringValue(behaviorAction->parameterValueString); + // valueAsString->SetValue(behaviorAction->parameterValueString); // thisAction->InsertValue(behaviorAction->parameterName, valueAsString); // } // else if (behaviorAction->parameterValueDouble != 0.0) // { // AMFDoubleValue* valueAsDouble = new AMFDoubleValue(); - // valueAsDouble->SetDoubleValue(behaviorAction->parameterValueDouble); + // valueAsDouble->SetValue(behaviorAction->parameterValueDouble); // thisAction->InsertValue(behaviorAction->parameterName, valueAsDouble); // } // stripSerialize->PushBackValue(thisAction); @@ -237,11 +232,11 @@ void ControlBehaviors::SendBehaviorBlocksToClient(ModelComponent* modelComponent // behaviorInfo.InsertValue("states", stateSerialize); // AMFStringValue* objectidAsString = new AMFStringValue(); - // objectidAsString->SetStringValue(std::to_string(targetObjectID)); + // objectidAsString->SetValue(std::to_string(targetObjectID)); // behaviorInfo.InsertValue("objectID", objectidAsString); // AMFStringValue* behaviorIDAsString = new AMFStringValue(); - // behaviorIDAsString->SetStringValue(std::to_string(behaviorID)); + // behaviorIDAsString->SetValue(std::to_string(behaviorID)); // behaviorInfo.InsertValue("BehaviorID", behaviorIDAsString); // GameMessages::SendUIMessageServerToSingleClient(modelOwner, sysAddr, "UpdateBehaviorBlocks", &behaviorInfo); @@ -275,10 +270,9 @@ void ControlBehaviors::MoveToInventory(ModelComponent* modelComponent, const Sys // This closes the UI menu should it be open while the player is removing behaviors AMFArrayValue args; - AMFFalseValue* stateToPop = new AMFFalseValue(); - args.InsertValue("visible", stateToPop); + args.Insert("visible", false); - GameMessages::SendUIMessageServerToSingleClient(modelOwner, modelOwner->GetParentUser()->GetSystemAddress(), "ToggleBehaviorEditor", &args); + GameMessages::SendUIMessageServerToSingleClient(modelOwner, modelOwner->GetParentUser()->GetSystemAddress(), "ToggleBehaviorEditor", args); MoveToInventoryMessage moveToInventoryMessage(arguments); diff --git a/dGame/dUtilities/Loot.cpp b/dGame/dUtilities/Loot.cpp index da0f2487..c788c016 100644 --- a/dGame/dUtilities/Loot.cpp +++ b/dGame/dUtilities/Loot.cpp @@ -318,13 +318,13 @@ void LootGenerator::GiveActivityLoot(Entity* player, Entity* source, uint32_t ac maxCoins = currencyTable[0].maxvalue; } - GiveLoot(player, selectedReward->LootMatrixIndex, eLootSourceType::LOOT_SOURCE_ACTIVITY); + GiveLoot(player, selectedReward->LootMatrixIndex, eLootSourceType::ACTIVITY); uint32_t coins = (int)(minCoins + GeneralUtils::GenerateRandomNumber(0, 1) * (maxCoins - minCoins)); auto* character = player->GetCharacter(); - character->SetCoins(character->GetCoins() + coins, eLootSourceType::LOOT_SOURCE_ACTIVITY); + character->SetCoins(character->GetCoins() + coins, eLootSourceType::ACTIVITY); } void LootGenerator::DropLoot(Entity* player, Entity* killedObject, uint32_t matrixIndex, uint32_t minCoins, uint32_t maxCoins) { diff --git a/dGame/dUtilities/Loot.h b/dGame/dUtilities/Loot.h index 7ecc22b8..a1c52b63 100644 --- a/dGame/dUtilities/Loot.h +++ b/dGame/dUtilities/Loot.h @@ -47,8 +47,8 @@ public: std::unordered_map RollLootMatrix(Entity* player, uint32_t matrixIndex); std::unordered_map RollLootMatrix(uint32_t matrixIndex); - void GiveLoot(Entity* player, uint32_t matrixIndex, eLootSourceType lootSourceType = eLootSourceType::LOOT_SOURCE_NONE); - void GiveLoot(Entity* player, std::unordered_map& result, eLootSourceType lootSourceType = eLootSourceType::LOOT_SOURCE_NONE); + void GiveLoot(Entity* player, uint32_t matrixIndex, eLootSourceType lootSourceType = eLootSourceType::NONE); + void GiveLoot(Entity* player, std::unordered_map& result, eLootSourceType lootSourceType = eLootSourceType::NONE); void GiveActivityLoot(Entity* player, Entity* source, uint32_t activityID, int32_t rating = 0); void DropLoot(Entity* player, Entity* killedObject, uint32_t matrixIndex, uint32_t minCoins, uint32_t maxCoins); void DropLoot(Entity* player, Entity* killedObject, std::unordered_map& result, uint32_t minCoins, uint32_t maxCoins); diff --git a/dGame/dUtilities/Mail.cpp b/dGame/dUtilities/Mail.cpp index 9490f748..5dc55765 100644 --- a/dGame/dUtilities/Mail.cpp +++ b/dGame/dUtilities/Mail.cpp @@ -13,7 +13,6 @@ #include "Entity.h" #include "Character.h" #include "PacketUtils.h" -#include "dMessageIdentifiers.h" #include "dLogger.h" #include "EntityManager.h" #include "InventoryComponent.h" @@ -26,6 +25,7 @@ #include "WorldConfig.h" #include "eMissionTaskType.h" #include "eReplicaComponentType.h" +#include "eConnectionType.h" void Mail::SendMail(const Entity* recipient, const std::string& subject, const std::string& body, const LOT attachment, const uint16_t attachmentCount) { @@ -130,7 +130,7 @@ void Mail::HandleMailStuff(RakNet::BitStream* packet, const SystemAddress& sysAd int mailStuffID = 0; packet->Read(mailStuffID); - std::async(std::launch::async, [packet, &sysAddr, entity, mailStuffID]() { + auto returnVal = std::async(std::launch::async, [packet, &sysAddr, entity, mailStuffID]() { Mail::MailMessageID stuffID = MailMessageID(mailStuffID); switch (stuffID) { case MailMessageID::AttachmentCollect: @@ -259,7 +259,7 @@ void Mail::HandleSendMail(RakNet::BitStream* packet, const SystemAddress& sysAdd } Mail::SendSendResponse(sysAddr, Mail::MailSendResponse::Success); - entity->GetCharacter()->SetCoins(entity->GetCharacter()->GetCoins() - mailCost, eLootSourceType::LOOT_SOURCE_MAIL); + entity->GetCharacter()->SetCoins(entity->GetCharacter()->GetCoins() - mailCost, eLootSourceType::MAIL); Game::logger->Log("Mail", "Seeing if we need to remove item with ID/count/LOT: %i %i %i", itemID, attachmentCount, itemLOT); @@ -283,7 +283,7 @@ void Mail::HandleDataRequest(RakNet::BitStream* packet, const SystemAddress& sys sql::ResultSet* res = stmt->executeQuery(); RakNet::BitStream bitStream; - PacketUtils::WriteHeader(bitStream, CLIENT, MSG_CLIENT_MAIL); + PacketUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::MAIL); bitStream.Write(int(MailMessageID::MailData)); bitStream.Write(int(0)); @@ -359,7 +359,7 @@ void Mail::HandleAttachmentCollect(RakNet::BitStream* packet, const SystemAddres auto inv = static_cast(player->GetComponent(eReplicaComponentType::INVENTORY)); if (!inv) return; - inv->AddItem(attachmentLOT, attachmentCount, eLootSourceType::LOOT_SOURCE_MAIL); + inv->AddItem(attachmentLOT, attachmentCount, eLootSourceType::MAIL); Mail::SendAttachmentRemoveConfirm(sysAddr, mailID); @@ -393,7 +393,7 @@ void Mail::HandleMailRead(RakNet::BitStream* packet, const SystemAddress& sysAdd } void Mail::HandleNotificationRequest(const SystemAddress& sysAddr, uint32_t objectID) { - std::async(std::launch::async, [&]() { + auto returnVal = std::async(std::launch::async, [&]() { sql::PreparedStatement* stmt = Database::CreatePreppedStmt("SELECT id FROM mail WHERE receiver_id=? AND was_read=0"); stmt->setUInt(1, objectID); sql::ResultSet* res = stmt->executeQuery(); @@ -406,7 +406,7 @@ void Mail::HandleNotificationRequest(const SystemAddress& sysAddr, uint32_t obje void Mail::SendSendResponse(const SystemAddress& sysAddr, MailSendResponse response) { RakNet::BitStream bitStream; - PacketUtils::WriteHeader(bitStream, CLIENT, MSG_CLIENT_MAIL); + PacketUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::MAIL); bitStream.Write(int(MailMessageID::SendResponse)); bitStream.Write(int(response)); Game::server->Send(&bitStream, sysAddr, false); @@ -414,7 +414,7 @@ void Mail::SendSendResponse(const SystemAddress& sysAddr, MailSendResponse respo void Mail::SendNotification(const SystemAddress& sysAddr, int mailCount) { RakNet::BitStream bitStream; - PacketUtils::WriteHeader(bitStream, CLIENT, MSG_CLIENT_MAIL); + PacketUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::MAIL); uint64_t messageType = 2; uint64_t s1 = 0; uint64_t s2 = 0; @@ -433,7 +433,7 @@ void Mail::SendNotification(const SystemAddress& sysAddr, int mailCount) { void Mail::SendAttachmentRemoveConfirm(const SystemAddress& sysAddr, uint64_t mailID) { RakNet::BitStream bitStream; - PacketUtils::WriteHeader(bitStream, CLIENT, MSG_CLIENT_MAIL); + PacketUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::MAIL); bitStream.Write(int(MailMessageID::AttachmentCollectConfirm)); bitStream.Write(int(0)); //unknown bitStream.Write(mailID); @@ -442,7 +442,7 @@ void Mail::SendAttachmentRemoveConfirm(const SystemAddress& sysAddr, uint64_t ma void Mail::SendDeleteConfirm(const SystemAddress& sysAddr, uint64_t mailID, LWOOBJID playerID) { RakNet::BitStream bitStream; - PacketUtils::WriteHeader(bitStream, CLIENT, MSG_CLIENT_MAIL); + PacketUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::MAIL); bitStream.Write(int(MailMessageID::MailDeleteConfirm)); bitStream.Write(int(0)); //unknown bitStream.Write(mailID); @@ -456,7 +456,7 @@ void Mail::SendDeleteConfirm(const SystemAddress& sysAddr, uint64_t mailID, LWOO void Mail::SendReadConfirm(const SystemAddress& sysAddr, uint64_t mailID) { RakNet::BitStream bitStream; - PacketUtils::WriteHeader(bitStream, CLIENT, MSG_CLIENT_MAIL); + PacketUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::MAIL); bitStream.Write(int(MailMessageID::MailReadConfirm)); bitStream.Write(int(0)); //unknown bitStream.Write(mailID); diff --git a/dGame/dUtilities/SlashCommandHandler.cpp b/dGame/dUtilities/SlashCommandHandler.cpp index e4edaa4a..b65bf723 100644 --- a/dGame/dUtilities/SlashCommandHandler.cpp +++ b/dGame/dUtilities/SlashCommandHandler.cpp @@ -69,58 +69,42 @@ #include "BinaryPathFinder.h" #include "dConfig.h" #include "eBubbleType.h" -#include "AMFFormat.h" +#include "Amf3.h" #include "MovingPlatformComponent.h" -#include "dMessageIdentifiers.h" #include "eMissionState.h" #include "TriggerComponent.h" #include "eServerDisconnectIdentifiers.h" +#include "eObjectBits.h" #include "eGameMasterLevel.h" #include "eReplicaComponentType.h" #include "RenderComponent.h" +#include "eControlScheme.h" +#include "eConnectionType.h" +#include "eChatInternalMessageType.h" +#include "eMasterMessageType.h" #include "CDObjectsTable.h" #include "CDZoneTableTable.h" void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entity* entity, const SystemAddress& sysAddr) { + auto commandCopy = command; + // Sanity check that a command was given + if (command.empty() || command.front() != u'/') return; + commandCopy.erase(commandCopy.begin()); + + // Split the command by spaces std::string chatCommand; std::vector args; + auto wideCommand = GeneralUtils::SplitString(commandCopy, u' '); + if (wideCommand.empty()) return; - uint32_t breakIndex = 0; - for (uint32_t i = 1; i < command.size(); ++i) { - if (command[i] == L' ') { - breakIndex = i; - break; - } + // Convert the command to lowercase + chatCommand = GeneralUtils::UTF16ToWTF8(wideCommand.front()); + std::transform(chatCommand.begin(), chatCommand.end(), chatCommand.begin(), ::tolower); + wideCommand.erase(wideCommand.begin()); - chatCommand.push_back(static_cast(command[i])); - breakIndex++; - } - - uint32_t index = ++breakIndex; - while (true) { - std::string arg; - - while (index < command.size()) { - if (command[index] == L' ') { - args.push_back(arg); - arg = ""; - index++; - continue; - } - - arg.push_back(static_cast(command[index])); - index++; - } - - if (arg != "") { - args.push_back(arg); - } - - break; - } - - //Game::logger->Log("SlashCommandHandler", "Received chat command \"%s\"", GeneralUtils::UTF16ToWTF8(command).c_str()); + // Convert the arguements to not u16strings + for (auto wideArg : wideCommand) args.push_back(GeneralUtils::UTF16ToWTF8(wideArg)); User* user = UserManager::Instance()->GetUser(sysAddr); if ((chatCommand == "setgmlevel" || chatCommand == "makegm" || chatCommand == "gmlevel") && user->GetMaxGMLevel() > eGameMasterLevel::CIVILIAN) { @@ -174,7 +158,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit } #endif - if (chatCommand == "togglenameplate" && (Game::config->GetValue("allownameplateoff") == "1" || entity->GetGMLevel() > eGameMasterLevel::DEVELOPER)) { + if (chatCommand == "togglenameplate" && (Game::config->GetValue("allow_nameplate_off") == "1" || entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER)) { auto* character = entity->GetCharacter(); if (character && character->GetBillboardVisible()) { @@ -268,26 +252,20 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit { AMFArrayValue args; - auto* state = new AMFStringValue(); - state->SetStringValue("Story"); + args.Insert("state", "Story"); - args.InsertValue("state", state); - - GameMessages::SendUIMessageServerToSingleClient(entity, entity->GetSystemAddress(), "pushGameState", &args); + GameMessages::SendUIMessageServerToSingleClient(entity, entity->GetSystemAddress(), "pushGameState", args); } entity->AddCallbackTimer(0.5f, [customText, entity]() { AMFArrayValue args; - auto* text = new AMFStringValue(); - text->SetStringValue(customText); - - args.InsertValue("visible", new AMFTrueValue()); - args.InsertValue("text", text); + args.Insert("visible", true); + args.Insert("text", customText); Game::logger->Log("SlashCommandHandler", "Sending %s", customText.c_str()); - GameMessages::SendUIMessageServerToSingleClient(entity, entity->GetSystemAddress(), "ToggleStoryBox", &args); + GameMessages::SendUIMessageServerToSingleClient(entity, entity->GetSystemAddress(), "ToggleStoryBox", args); }); return; @@ -296,7 +274,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit if (chatCommand == "leave-zone") { const auto currentZone = dZoneManager::Instance()->GetZone()->GetZoneID().GetMapID(); - auto newZone = 0; + LWOMAPID newZone = 0; if (currentZone % 100 == 0) { ChatPackets::SendSystemMessage(sysAddr, u"You are not in an instanced zone."); return; @@ -304,7 +282,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit newZone = (currentZone / 100) * 100; } // If new zone would be inaccessible, then default to Avant Gardens. - if (!CheckIfAccessibleZone(newZone)) newZone = 1100; + if (!dZoneManager::Instance()->CheckIfAccessibleZone(newZone)) newZone = 1100; ChatPackets::SendSystemMessage(sysAddr, u"Leaving zone..."); @@ -517,7 +495,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit const auto state = !entity->GetVar(u"freecam"); entity->SetVar(u"freecam", state); - GameMessages::SendSetPlayerControlScheme(entity, static_cast(state ? 9 : 1)); + GameMessages::SendSetPlayerControlScheme(entity, static_cast(state ? 9 : 1)); ChatPackets::SendSystemMessage(sysAddr, u"Toggled freecam."); return; @@ -531,7 +509,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit return; } - GameMessages::SendSetPlayerControlScheme(entity, static_cast(scheme)); + GameMessages::SendSetPlayerControlScheme(entity, static_cast(scheme)); ChatPackets::SendSystemMessage(sysAddr, u"Switched control scheme."); return; @@ -547,12 +525,11 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit } if (chatCommand == "setuistate" && args.size() == 1 && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) { - AMFStringValue* value = new AMFStringValue(); - value->SetStringValue(args[0]); + AMFArrayValue uiState; - AMFArrayValue args; - args.InsertValue("state", value); - GameMessages::SendUIMessageServerToSingleClient(entity, sysAddr, "pushGameState", &args); + uiState.Insert("state", args.at(0)); + + GameMessages::SendUIMessageServerToSingleClient(entity, sysAddr, "pushGameState", uiState); ChatPackets::SendSystemMessage(sysAddr, u"Switched UI state."); @@ -560,11 +537,11 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit } if (chatCommand == "toggle" && args.size() == 1 && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) { - AMFTrueValue* value = new AMFTrueValue(); - AMFArrayValue amfArgs; - amfArgs.InsertValue("visible", value); - GameMessages::SendUIMessageServerToSingleClient(entity, sysAddr, args[0], &amfArgs); + + amfArgs.Insert("visible", true); + + GameMessages::SendUIMessageServerToSingleClient(entity, sysAddr, args[0], amfArgs); ChatPackets::SendSystemMessage(sysAddr, u"Toggled UI state."); @@ -673,7 +650,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit } if (chatCommand == "setflag" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER && args.size() == 1) { - uint32_t flagId; + int32_t flagId; if (!GeneralUtils::TryParse(args[0], flagId)) { ChatPackets::SendSystemMessage(sysAddr, u"Invalid flag id."); @@ -684,7 +661,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit } if (chatCommand == "setflag" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER && args.size() == 2) { - uint32_t flagId; + int32_t flagId; std::string onOffFlag = args[0]; if (!GeneralUtils::TryParse(args[1], flagId)) { ChatPackets::SendSystemMessage(sysAddr, u"Invalid flag id."); @@ -697,7 +674,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit entity->GetCharacter()->SetPlayerFlag(flagId, onOffFlag == "on"); } if (chatCommand == "clearflag" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER && args.size() == 1) { - uint32_t flagId; + int32_t flagId; if (!GeneralUtils::TryParse(args[0], flagId)) { ChatPackets::SendSystemMessage(sysAddr, u"Invalid flag id."); @@ -784,7 +761,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit if (chatCommand == "shutdownuniverse" && entity->GetGMLevel() == eGameMasterLevel::OPERATOR) { //Tell the master server that we're going to be shutting down whole "universe": CBITSTREAM; - PacketUtils::WriteHeader(bitStream, MASTER, MSG_MASTER_SHUTDOWN_UNIVERSE); + PacketUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::SHUTDOWN_UNIVERSE); Game::server->SendToMaster(&bitStream); ChatPackets::SendSystemMessage(sysAddr, u"Sent universe shutdown notification to master."); @@ -813,7 +790,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit InventoryComponent* inventory = static_cast(entity->GetComponent(eReplicaComponentType::INVENTORY)); - inventory->AddItem(itemLOT, 1, eLootSourceType::LOOT_SOURCE_MODERATION); + inventory->AddItem(itemLOT, 1, eLootSourceType::MODERATION); } else if (args.size() == 2) { uint32_t itemLOT; @@ -831,7 +808,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit InventoryComponent* inventory = static_cast(entity->GetComponent(eReplicaComponentType::INVENTORY)); - inventory->AddItem(itemLOT, count, eLootSourceType::LOOT_SOURCE_MODERATION); + inventory->AddItem(itemLOT, count, eLootSourceType::MODERATION); } else { ChatPackets::SendSystemMessage(sysAddr, u"Correct usage: /gmadditem "); } @@ -1050,8 +1027,8 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit accountId = result->getUInt(1); characterId = result->getUInt64(2); - characterId = GeneralUtils::SetBit(characterId, OBJECT_BIT_CHARACTER); - characterId = GeneralUtils::SetBit(characterId, OBJECT_BIT_PERSISTENT); + GeneralUtils::SetBit(characterId, eObjectBits::CHARACTER); + GeneralUtils::SetBit(characterId, eObjectBits::PERSISTENT); } } @@ -1115,7 +1092,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit //Notify chat about it CBITSTREAM; - PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_MUTE_UPDATE); + PacketUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::MUTE_UPDATE); bitStream.Write(characterId); bitStream.Write(expire); @@ -1366,9 +1343,9 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit CharacterComponent* character = entity->GetComponent(); if (character) character->SetUScore(character->GetUScore() + uscore); - // LOOT_SOURCE_MODERATION should work but it doesn't. Relog to see uscore changes + // MODERATION should work but it doesn't. Relog to see uscore changes - eLootSourceType lootType = eLootSourceType::LOOT_SOURCE_MODERATION; + eLootSourceType lootType = eLootSourceType::MODERATION; int32_t type; if (args.size() >= 2 && GeneralUtils::TryParse(args[1], type)) { @@ -1486,7 +1463,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit } auto* ch = entity->GetCharacter(); - ch->SetCoins(ch->GetCoins() + money, eLootSourceType::LOOT_SOURCE_MODERATION); + ch->SetCoins(ch->GetCoins() + money, eLootSourceType::MODERATION); } if ((chatCommand == "setcurrency") && args.size() == 1 && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) { @@ -1498,7 +1475,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit } auto* ch = entity->GetCharacter(); - ch->SetCoins(money, eLootSourceType::LOOT_SOURCE_MODERATION); + ch->SetCoins(money, eLootSourceType::MODERATION); } // Allow for this on even while not a GM, as it sometimes toggles incorrrectly. @@ -1576,7 +1553,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit const auto objid = entity->GetObjectID(); - if (force || CheckIfAccessibleZone(reqZone)) { // to prevent tomfoolery + if (force || dZoneManager::Instance()->CheckIfAccessibleZone(reqZone)) { // to prevent tomfoolery ZoneInstanceManager::Instance()->RequestZoneTransfer(Game::server, reqZone, cloneId, false, [objid](bool mythranShift, uint32_t zoneID, uint32_t zoneInstance, uint32_t zoneClone, std::string serverIP, uint16_t serverPort) { @@ -1634,7 +1611,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit if ((chatCommand == "debugui") && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) { ChatPackets::SendSystemMessage(sysAddr, u"Opening UIDebugger..."); AMFArrayValue args; - GameMessages::SendUIMessageServerToSingleClient(entity, sysAddr, "ToggleUIDebugger;", nullptr); + GameMessages::SendUIMessageServerToSingleClient(entity, sysAddr, "ToggleUIDebugger;", args); } if ((chatCommand == "boost") && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) { @@ -1747,7 +1724,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit std::vector data{}; data.push_back(new LDFData(u"reforgedLOT", reforgedItem)); - inventoryComponent->AddItem(baseItem, 1, eLootSourceType::LOOT_SOURCE_MODERATION, eInventoryType::INVALID, data); + inventoryComponent->AddItem(baseItem, 1, eLootSourceType::MODERATION, eInventoryType::INVALID, data); } if (chatCommand == "crash" && entity->GetGMLevel() >= eGameMasterLevel::OPERATOR) { @@ -2038,32 +2015,17 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit } } -bool SlashCommandHandler::CheckIfAccessibleZone(const unsigned int zoneID) { - //We're gonna go ahead and presume we've got the db loaded already: - CDZoneTableTable* zoneTable = CDClientManager::Instance().GetTable(); - const CDZoneTable* zone = zoneTable->Query(zoneID); - if (zone != nullptr) { - return Game::assetManager->HasFile(("maps/" + zone->zoneName).c_str()); - } else { - return false; - } -} - void SlashCommandHandler::SendAnnouncement(const std::string& title, const std::string& message) { AMFArrayValue args; - auto* titleValue = new AMFStringValue(); - titleValue->SetStringValue(title); - auto* messageValue = new AMFStringValue(); - messageValue->SetStringValue(message); - args.InsertValue("title", titleValue); - args.InsertValue("message", messageValue); + args.Insert("title", title); + args.Insert("message", message); - GameMessages::SendUIMessageServerToAllClients("ToggleAnnounce", &args); + GameMessages::SendUIMessageServerToAllClients("ToggleAnnounce", args); //Notify chat about it CBITSTREAM; - PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_ANNOUNCEMENT); + PacketUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::ANNOUNCEMENT); bitStream.Write(title.size()); for (auto character : title) { diff --git a/dGame/dUtilities/SlashCommandHandler.h b/dGame/dUtilities/SlashCommandHandler.h index 9ef09a2f..85b7c697 100644 --- a/dGame/dUtilities/SlashCommandHandler.h +++ b/dGame/dUtilities/SlashCommandHandler.h @@ -13,8 +13,6 @@ class Entity; namespace SlashCommandHandler { void HandleChatCommand(const std::u16string& command, Entity* entity, const SystemAddress& sysAddr); - bool CheckIfAccessibleZone(const unsigned int zoneID); - void SendAnnouncement(const std::string& title, const std::string& message); }; diff --git a/dMasterServer/InstanceManager.cpp b/dMasterServer/InstanceManager.cpp index fe62a5e5..50f55b72 100644 --- a/dMasterServer/InstanceManager.cpp +++ b/dMasterServer/InstanceManager.cpp @@ -7,10 +7,11 @@ #include "CDClientDatabase.h" #include "CDClientManager.h" #include "CDZoneTableTable.h" -#include "dMessageIdentifiers.h" #include "MasterPackets.h" #include "PacketUtils.h" #include "BinaryPathFinder.h" +#include "eConnectionType.h" +#include "eMasterMessageType.h" InstanceManager::InstanceManager(dLogger* logger, const std::string& externalIP) { mLogger = logger; @@ -201,7 +202,7 @@ void InstanceManager::RequestAffirmation(Instance* instance, const PendingInstan CBITSTREAM; - PacketUtils::WriteHeader(bitStream, MASTER, MSG_MASTER_AFFIRM_TRANSFER_REQUEST); + PacketUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::AFFIRM_TRANSFER_REQUEST); bitStream.Write(request.id); @@ -405,7 +406,7 @@ bool Instance::GetShutdownComplete() const { void Instance::Shutdown() { CBITSTREAM; - PacketUtils::WriteHeader(bitStream, MASTER, MSG_MASTER_SHUTDOWN); + PacketUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::SHUTDOWN); Game::server->Send(&bitStream, this->m_SysAddr, false); diff --git a/dMasterServer/MasterServer.cpp b/dMasterServer/MasterServer.cpp index 78c93328..ce237eac 100644 --- a/dMasterServer/MasterServer.cpp +++ b/dMasterServer/MasterServer.cpp @@ -27,6 +27,8 @@ #include "dServer.h" #include "AssetManager.h" #include "BinaryPathFinder.h" +#include "eConnectionType.h" +#include "eMasterMessageType.h" //RakNet includes: #include "RakNetDefines.h" @@ -39,7 +41,6 @@ #include "MasterPackets.h" #include "ObjectIDManager.h" #include "PacketUtils.h" -#include "dMessageIdentifiers.h" #include "FdbToSqlite.h" namespace Game { @@ -336,7 +337,6 @@ int main(int argc, char** argv) { Game::im->GetInstance(0, false, 0); Game::im->GetInstance(1000, false, 0); - StartAuthServer(); } @@ -496,9 +496,11 @@ void HandlePacket(Packet* packet) { } } - if (packet->data[1] == MASTER) { - switch (packet->data[3]) { - case MSG_MASTER_REQUEST_PERSISTENT_ID: { + if (packet->length < 4) return; + + if (static_cast(packet->data[1]) == eConnectionType::MASTER) { + switch (static_cast(packet->data[3])) { + case eMasterMessageType::REQUEST_PERSISTENT_ID: { Game::logger->Log("MasterServer", "A persistent ID req"); RakNet::BitStream inStream(packet->data, packet->length, false); uint64_t header = inStream.Read(header); @@ -510,7 +512,7 @@ void HandlePacket(Packet* packet) { break; } - case MSG_MASTER_REQUEST_ZONE_TRANSFER: { + case eMasterMessageType::REQUEST_ZONE_TRANSFER: { Game::logger->Log("MasterServer", "Received zone transfer req"); RakNet::BitStream inStream(packet->data, packet->length, false); uint64_t header = inStream.Read(header); @@ -546,7 +548,7 @@ void HandlePacket(Packet* packet) { break; } - case MSG_MASTER_SERVER_INFO: { + case eMasterMessageType::SERVER_INFO: { //MasterPackets::HandleServerInfo(packet); //This is here because otherwise we'd have to include IM in @@ -605,7 +607,7 @@ void HandlePacket(Packet* packet) { break; } - case MSG_MASTER_SET_SESSION_KEY: { + case eMasterMessageType::SET_SESSION_KEY: { RakNet::BitStream inStream(packet->data, packet->length, false); uint64_t header = inStream.Read(header); uint32_t sessionKey = 0; @@ -619,7 +621,7 @@ void HandlePacket(Packet* packet) { activeSessions.erase(it.first); CBITSTREAM; - PacketUtils::WriteHeader(bitStream, MASTER, MSG_MASTER_NEW_SESSION_ALERT); + PacketUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::NEW_SESSION_ALERT); bitStream.Write(sessionKey); bitStream.Write(username.size()); for (auto character : username) { @@ -636,7 +638,7 @@ void HandlePacket(Packet* packet) { break; } - case MSG_MASTER_REQUEST_SESSION_KEY: { + case eMasterMessageType::REQUEST_SESSION_KEY: { RakNet::BitStream inStream(packet->data, packet->length, false); uint64_t header = inStream.Read(header); std::string username = PacketUtils::ReadString(8, packet, false); @@ -644,7 +646,7 @@ void HandlePacket(Packet* packet) { for (auto key : activeSessions) { if (key.second == username) { CBITSTREAM; - PacketUtils::WriteHeader(bitStream, MASTER, MSG_MASTER_SESSION_KEY_RESPONSE); + PacketUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::SESSION_KEY_RESPONSE); bitStream.Write(key.first); PacketUtils::WriteString(bitStream, key.second, 64); Game::server->Send(&bitStream, packet->systemAddress, false); @@ -654,7 +656,7 @@ void HandlePacket(Packet* packet) { break; } - case MSG_MASTER_PLAYER_ADDED: { + case eMasterMessageType::PLAYER_ADDED: { RakNet::BitStream inStream(packet->data, packet->length, false); uint64_t header = inStream.Read(header); @@ -674,7 +676,7 @@ void HandlePacket(Packet* packet) { break; } - case MSG_MASTER_PLAYER_REMOVED: { + case eMasterMessageType::PLAYER_REMOVED: { RakNet::BitStream inStream(packet->data, packet->length, false); uint64_t header = inStream.Read(header); @@ -692,7 +694,7 @@ void HandlePacket(Packet* packet) { break; } - case MSG_MASTER_CREATE_PRIVATE_ZONE: { + case eMasterMessageType::CREATE_PRIVATE_ZONE: { RakNet::BitStream inStream(packet->data, packet->length, false); uint64_t header = inStream.Read(header); @@ -716,7 +718,7 @@ void HandlePacket(Packet* packet) { break; } - case MSG_MASTER_REQUEST_PRIVATE_ZONE: { + case eMasterMessageType::REQUEST_PRIVATE_ZONE: { RakNet::BitStream inStream(packet->data, packet->length, false); uint64_t header = inStream.Read(header); @@ -751,7 +753,7 @@ void HandlePacket(Packet* packet) { break; } - case MSG_MASTER_WORLD_READY: { + case eMasterMessageType::WORLD_READY: { RakNet::BitStream inStream(packet->data, packet->length, false); uint64_t header = inStream.Read(header); @@ -775,7 +777,7 @@ void HandlePacket(Packet* packet) { break; } - case MSG_MASTER_PREP_ZONE: { + case eMasterMessageType::PREP_ZONE: { RakNet::BitStream inStream(packet->data, packet->length, false); uint64_t header = inStream.Read(header); @@ -791,7 +793,7 @@ void HandlePacket(Packet* packet) { break; } - case MSG_MASTER_AFFIRM_TRANSFER_RESPONSE: { + case eMasterMessageType::AFFIRM_TRANSFER_RESPONSE: { RakNet::BitStream inStream(packet->data, packet->length, false); uint64_t header = inStream.Read(header); @@ -811,7 +813,7 @@ void HandlePacket(Packet* packet) { break; } - case MSG_MASTER_SHUTDOWN_RESPONSE: { + case eMasterMessageType::SHUTDOWN_RESPONSE: { RakNet::BitStream inStream(packet->data, packet->length, false); uint64_t header = inStream.Read(header); @@ -826,7 +828,7 @@ void HandlePacket(Packet* packet) { break; } - case MSG_MASTER_SHUTDOWN_UNIVERSE: { + case eMasterMessageType::SHUTDOWN_UNIVERSE: { Game::logger->Log("MasterServer", "Received shutdown universe command, shutting down in 10 minutes."); Game::shouldShutdown = true; break; @@ -890,7 +892,7 @@ void ShutdownSequence(int32_t signal) { { CBITSTREAM; - PacketUtils::WriteHeader(bitStream, MASTER, MSG_MASTER_SHUTDOWN); + PacketUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::SHUTDOWN); Game::server->Send(&bitStream, UNASSIGNED_SYSTEM_ADDRESS, true); Game::logger->Log("MasterServer", "Triggered master shutdown"); } diff --git a/dNet/AuthPackets.cpp b/dNet/AuthPackets.cpp index 4e7cb0a6..4bbb0576 100644 --- a/dNet/AuthPackets.cpp +++ b/dNet/AuthPackets.cpp @@ -1,6 +1,5 @@ #include "AuthPackets.h" #include "PacketUtils.h" -#include "dMessageIdentifiers.h" #include "dNetCommon.h" #include "dServer.h" @@ -22,6 +21,10 @@ #include "Game.h" #include "dConfig.h" #include "eServerDisconnectIdentifiers.h" +#include "eLoginResponse.h" +#include "eConnectionType.h" +#include "eServerMessageType.h" +#include "eMasterMessageType.h" void AuthPackets::HandleHandshake(dServer* server, Packet* packet) { RakNet::BitStream inStream(packet->data, packet->length, false); @@ -35,7 +38,7 @@ void AuthPackets::HandleHandshake(dServer* server, Packet* packet) { void AuthPackets::SendHandshake(dServer* server, const SystemAddress& sysAddr, const std::string& nextServerIP, uint16_t nextServerPort, const ServerType serverType) { RakNet::BitStream bitStream; - PacketUtils::WriteHeader(bitStream, SERVER, MSG_SERVER_VERSION_CONFIRM); + PacketUtils::WriteHeader(bitStream, eConnectionType::SERVER, eServerMessageType::VERSION_CONFIRM); bitStream.Write(NET_VERSION); bitStream.Write(uint32_t(0x93)); @@ -61,7 +64,7 @@ void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) { if (res->rowsCount() == 0) { server->GetLogger()->Log("AuthPackets", "No user found!"); - AuthPackets::SendLoginResponse(server, packet->systemAddress, LOGIN_RESPONSE_WRONG_PASS_OR_USER, "", "", 2001, username); + AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::INVALID_USER, "", "", 2001, username); return; } @@ -85,14 +88,14 @@ void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) { //If we aren't running in live mode, then only GMs are allowed to enter: const auto& closedToNonDevs = Game::config->GetValue("closed_to_non_devs"); if (closedToNonDevs.size() > 0 && bool(std::stoi(closedToNonDevs)) && sqlGmLevel == 0) { - AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::LOGIN_RESPONSE_PERMISSIONS_NOT_HIGH_ENOUGH, "The server is currently only open to developers.", "", 2001, username); + AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::PERMISSIONS_NOT_HIGH_ENOUGH, "The server is currently only open to developers.", "", 2001, username); return; } if (Game::config->GetValue("dont_use_keys") != "1") { //Check to see if we have a play key: if (sqlPlayKey == 0 && sqlGmLevel == 0) { - AuthPackets::SendLoginResponse(server, packet->systemAddress, LOGIN_RESPONSE_PERMISSIONS_NOT_HIGH_ENOUGH, "Your account doesn't have a play key associated with it!", "", 2001, username); + AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::PERMISSIONS_NOT_HIGH_ENOUGH, "Your account doesn't have a play key associated with it!", "", 2001, username); server->GetLogger()->Log("AuthPackets", "User %s tried to log in, but they don't have a play key.", username.c_str()); return; } @@ -104,7 +107,7 @@ void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) { bool isKeyActive = false; if (keyRes->rowsCount() == 0 && sqlGmLevel == 0) { - AuthPackets::SendLoginResponse(server, packet->systemAddress, LOGIN_RESPONSE_PERMISSIONS_NOT_HIGH_ENOUGH, "Your account doesn't have a play key associated with it!", "", 2001, username); + AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::PERMISSIONS_NOT_HIGH_ENOUGH, "Your account doesn't have a play key associated with it!", "", 2001, username); return; } @@ -113,18 +116,18 @@ void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) { } if (!isKeyActive && sqlGmLevel == 0) { - AuthPackets::SendLoginResponse(server, packet->systemAddress, LOGIN_RESPONSE_PERMISSIONS_NOT_HIGH_ENOUGH, "Your play key has been disabled.", "", 2001, username); + AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::PERMISSIONS_NOT_HIGH_ENOUGH, "Your play key has been disabled.", "", 2001, username); server->GetLogger()->Log("AuthPackets", "User %s tried to log in, but their play key was disabled", username.c_str()); return; } } if (sqlBanned) { - AuthPackets::SendLoginResponse(server, packet->systemAddress, LOGIN_RESPONSE_BANNED, "", "", 2001, username); return; + AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::BANNED, "", "", 2001, username); return; } if (sqlLocked) { - AuthPackets::SendLoginResponse(server, packet->systemAddress, LOGIN_RESPONSE_ACCOUNT_LOCKED, "", "", 2001, username); return; + AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::ACCOUNT_LOCKED, "", "", 2001, username); return; } /* @@ -170,25 +173,25 @@ void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) { } if (!loginSuccess) { - AuthPackets::SendLoginResponse(server, packet->systemAddress, LOGIN_RESPONSE_WRONG_PASS_OR_USER, "", "", 2001, username); + AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::WRONG_PASS, "", "", 2001, username); server->GetLogger()->Log("AuthPackets", "Wrong password used"); } else { SystemAddress system = packet->systemAddress; //Copy the sysAddr before the Packet gets destroyed from main if (!server->GetIsConnectedToMaster()) { - AuthPackets::SendLoginResponse(server, system, LOGIN_RESPONSE_GENERAL_FAILED, "", "", 0, username); + AuthPackets::SendLoginResponse(server, system, eLoginResponse::GENERAL_FAILED, "", "", 0, username); return; } ZoneInstanceManager::Instance()->RequestZoneTransfer(server, 0, 0, false, [system, server, username](bool mythranShift, uint32_t zoneID, uint32_t zoneInstance, uint32_t zoneClone, std::string zoneIP, uint16_t zonePort) { - AuthPackets::SendLoginResponse(server, system, LOGIN_RESPONSE_SUCCESS, "", zoneIP, zonePort, username); + AuthPackets::SendLoginResponse(server, system, eLoginResponse::SUCCESS, "", zoneIP, zonePort, username); }); } } void AuthPackets::SendLoginResponse(dServer* server, const SystemAddress& sysAddr, eLoginResponse responseCode, const std::string& errorMsg, const std::string& wServerIP, uint16_t wServerPort, std::string username) { RakNet::BitStream packet; - PacketUtils::WriteHeader(packet, CLIENT, MSG_CLIENT_LOGIN_RESPONSE); + PacketUtils::WriteHeader(packet, eConnectionType::CLIENT, eClientMessageType::LOGIN_RESPONSE); packet.Write(static_cast(responseCode)); @@ -254,7 +257,7 @@ void AuthPackets::SendLoginResponse(dServer* server, const SystemAddress& sysAdd //Inform the master server that we've created a session for this user: { CBITSTREAM; - PacketUtils::WriteHeader(bitStream, MASTER, MSG_MASTER_SET_SESSION_KEY); + PacketUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::SET_SESSION_KEY); bitStream.Write(sessionKey); PacketUtils::WriteString(bitStream, username, 66); server->SendToMaster(&bitStream); diff --git a/dNet/AuthPackets.h b/dNet/AuthPackets.h index 378a5862..0f004ca4 100644 --- a/dNet/AuthPackets.h +++ b/dNet/AuthPackets.h @@ -6,6 +6,7 @@ #include "dNetCommon.h" enum class ServerType : uint32_t; +enum class eLoginResponse : uint8_t; class dServer; namespace AuthPackets { diff --git a/dNet/ChatPackets.cpp b/dNet/ChatPackets.cpp index 2d592c9b..41661523 100644 --- a/dNet/ChatPackets.cpp +++ b/dNet/ChatPackets.cpp @@ -8,12 +8,13 @@ #include "BitStream.h" #include "Game.h" #include "PacketUtils.h" -#include "dMessageIdentifiers.h" #include "dServer.h" +#include "eConnectionType.h" +#include "eChatMessageType.h" void ChatPackets::SendChatMessage(const SystemAddress& sysAddr, char chatChannel, const std::string& senderName, LWOOBJID playerObjectID, bool senderMythran, const std::u16string& message) { CBITSTREAM; - PacketUtils::WriteHeader(bitStream, CHAT, MSG_CHAT_GENERAL_CHAT_MESSAGE); + PacketUtils::WriteHeader(bitStream, eConnectionType::CHAT, eChatMessageType::GENERAL_CHAT_MESSAGE); bitStream.Write(static_cast(0)); bitStream.Write(chatChannel); @@ -35,7 +36,7 @@ void ChatPackets::SendChatMessage(const SystemAddress& sysAddr, char chatChannel void ChatPackets::SendSystemMessage(const SystemAddress& sysAddr, const std::u16string& message, const bool broadcast) { CBITSTREAM; - PacketUtils::WriteHeader(bitStream, CHAT, MSG_CHAT_GENERAL_CHAT_MESSAGE); + PacketUtils::WriteHeader(bitStream, eConnectionType::CHAT, eChatMessageType::GENERAL_CHAT_MESSAGE); bitStream.Write(static_cast(0)); bitStream.Write(static_cast(4)); @@ -67,7 +68,7 @@ void ChatPackets::SendMessageFail(const SystemAddress& sysAddr) { //0x01 - "Upgrade to a full LEGO Universe Membership to chat with other players." CBITSTREAM; - PacketUtils::WriteHeader(bitStream, CLIENT, MSG_CLIENT_SEND_CANNED_TEXT); + PacketUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::SEND_CANNED_TEXT); bitStream.Write(0); //response type, options above ^ //docs say there's a wstring here-- no idea what it's for, or if it's even needed so leaving it as is for now. SEND_PACKET; diff --git a/dNet/ClientPackets.cpp b/dNet/ClientPackets.cpp index a1c08938..1c22bdcd 100644 --- a/dNet/ClientPackets.cpp +++ b/dNet/ClientPackets.cpp @@ -31,7 +31,6 @@ #include "dConfig.h" #include "CharacterComponent.h" #include "Database.h" -#include "dMessageIdentifiers.h" #include "eGameMasterLevel.h" #include "eReplicaComponentType.h" @@ -47,9 +46,7 @@ void ClientPackets::HandleChatMessage(const SystemAddress& sysAddr, Packet* pack return; } - CINSTREAM; - uint64_t header; - inStream.Read(header); + CINSTREAM_SKIP_HEADER; char chatChannel; uint16_t unknown; @@ -83,9 +80,7 @@ void ClientPackets::HandleClientPositionUpdate(const SystemAddress& sysAddr, Pac return; } - CINSTREAM; - uint64_t header; - inStream.Read(header); + CINSTREAM_SKIP_HEADER; Entity* entity = EntityManager::Instance()->GetEntity(user->GetLastUsedChar()->GetObjectID()); if (!entity) return; diff --git a/dNet/MasterPackets.cpp b/dNet/MasterPackets.cpp index e5b80e05..4233a37d 100644 --- a/dNet/MasterPackets.cpp +++ b/dNet/MasterPackets.cpp @@ -1,22 +1,23 @@ #include "MasterPackets.h" #include "BitStream.h" #include "PacketUtils.h" -#include "dMessageIdentifiers.h" #include "dCommonVars.h" #include "dServer.h" +#include "eConnectionType.h" +#include "eMasterMessageType.h" #include void MasterPackets::SendPersistentIDRequest(dServer* server, uint64_t requestID) { CBITSTREAM; - PacketUtils::WriteHeader(bitStream, MASTER, MSG_MASTER_REQUEST_PERSISTENT_ID); + PacketUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::REQUEST_PERSISTENT_ID); bitStream.Write(requestID); server->SendToMaster(&bitStream); } void MasterPackets::SendPersistentIDResponse(dServer* server, const SystemAddress& sysAddr, uint64_t requestID, uint32_t objID) { RakNet::BitStream bitStream; - PacketUtils::WriteHeader(bitStream, MASTER, MSG_MASTER_REQUEST_PERSISTENT_ID_RESPONSE); + PacketUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::REQUEST_PERSISTENT_ID_RESPONSE); bitStream.Write(requestID); bitStream.Write(objID); @@ -26,7 +27,7 @@ void MasterPackets::SendPersistentIDResponse(dServer* server, const SystemAddres void MasterPackets::SendZoneTransferRequest(dServer* server, uint64_t requestID, bool mythranShift, uint32_t zoneID, uint32_t cloneID) { RakNet::BitStream bitStream; - PacketUtils::WriteHeader(bitStream, MASTER, MSG_MASTER_REQUEST_ZONE_TRANSFER); + PacketUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::REQUEST_ZONE_TRANSFER); bitStream.Write(requestID); bitStream.Write(static_cast(mythranShift)); @@ -38,7 +39,7 @@ void MasterPackets::SendZoneTransferRequest(dServer* server, uint64_t requestID, void MasterPackets::SendZoneCreatePrivate(dServer* server, uint32_t zoneID, uint32_t cloneID, const std::string& password) { RakNet::BitStream bitStream; - PacketUtils::WriteHeader(bitStream, MASTER, MSG_MASTER_CREATE_PRIVATE_ZONE); + PacketUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::CREATE_PRIVATE_ZONE); bitStream.Write(zoneID); bitStream.Write(cloneID); @@ -53,7 +54,7 @@ void MasterPackets::SendZoneCreatePrivate(dServer* server, uint32_t zoneID, uint void MasterPackets::SendZoneRequestPrivate(dServer* server, uint64_t requestID, bool mythranShift, const std::string& password) { RakNet::BitStream bitStream; - PacketUtils::WriteHeader(bitStream, MASTER, MSG_MASTER_REQUEST_PRIVATE_ZONE); + PacketUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::REQUEST_PRIVATE_ZONE); bitStream.Write(requestID); bitStream.Write(static_cast(mythranShift)); @@ -68,7 +69,7 @@ void MasterPackets::SendZoneRequestPrivate(dServer* server, uint64_t requestID, void MasterPackets::SendWorldReady(dServer* server, LWOMAPID zoneId, LWOINSTANCEID instanceId) { RakNet::BitStream bitStream; - PacketUtils::WriteHeader(bitStream, MASTER, MSG_MASTER_WORLD_READY); + PacketUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::WORLD_READY); bitStream.Write(zoneId); bitStream.Write(instanceId); @@ -78,7 +79,7 @@ void MasterPackets::SendWorldReady(dServer* server, LWOMAPID zoneId, LWOINSTANCE void MasterPackets::SendZoneTransferResponse(dServer* server, const SystemAddress& sysAddr, uint64_t requestID, bool mythranShift, uint32_t zoneID, uint32_t zoneInstance, uint32_t zoneClone, const std::string& serverIP, uint32_t serverPort) { RakNet::BitStream bitStream; - PacketUtils::WriteHeader(bitStream, MASTER, MSG_MASTER_REQUEST_ZONE_TRANSFER_RESPONSE); + PacketUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::REQUEST_ZONE_TRANSFER_RESPONSE); bitStream.Write(requestID); bitStream.Write(static_cast(mythranShift)); @@ -110,7 +111,7 @@ void MasterPackets::HandleServerInfo(Packet* packet) { void MasterPackets::SendServerInfo(dServer* server, Packet* packet) { RakNet::BitStream bitStream; - PacketUtils::WriteHeader(bitStream, MASTER, MSG_MASTER_SERVER_INFO); + PacketUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::SERVER_INFO); bitStream.Write(server->GetPort()); bitStream.Write(server->GetZoneID()); diff --git a/dNet/PacketUtils.cpp b/dNet/PacketUtils.cpp index 307ff633..77b314d6 100644 --- a/dNet/PacketUtils.cpp +++ b/dNet/PacketUtils.cpp @@ -1,17 +1,9 @@ #include "PacketUtils.h" -#include #include #include #include "dLogger.h" #include "Game.h" -void PacketUtils::WriteHeader(RakNet::BitStream& bitStream, uint16_t connectionType, uint32_t internalPacketID) { - bitStream.Write(MessageID(ID_USER_PACKET_ENUM)); - bitStream.Write(connectionType); - bitStream.Write(internalPacketID); - bitStream.Write(uint8_t(0)); -} - uint16_t PacketUtils::ReadPacketU16(uint32_t startLoc, Packet* packet) { if (startLoc + 2 > packet->length) return 0; diff --git a/dNet/PacketUtils.h b/dNet/PacketUtils.h index fbbd1839..d07759a0 100644 --- a/dNet/PacketUtils.h +++ b/dNet/PacketUtils.h @@ -1,11 +1,20 @@ #ifndef PACKETUTILS_H #define PACKETUTILS_H +#include #include #include +enum class eConnectionType : uint16_t; + namespace PacketUtils { - void WriteHeader(RakNet::BitStream& bitStream, uint16_t connectionType, uint32_t internalPacketID); + template + void WriteHeader(RakNet::BitStream& bitStream, eConnectionType connectionType, T internalPacketID) { + bitStream.Write(MessageID(ID_USER_PACKET_ENUM)); + bitStream.Write(connectionType); + bitStream.Write(static_cast(internalPacketID)); + bitStream.Write(0); + } uint16_t ReadPacketU16(uint32_t startLoc, Packet* packet); uint32_t ReadPacketU32(uint32_t startLoc, Packet* packet); diff --git a/dNet/WorldPackets.cpp b/dNet/WorldPackets.cpp index febb6bc1..5fce14d3 100644 --- a/dNet/WorldPackets.cpp +++ b/dNet/WorldPackets.cpp @@ -1,7 +1,6 @@ #include "dCommonVars.h" #include "WorldPackets.h" #include "BitStream.h" -#include "dMessageIdentifiers.h" #include "PacketUtils.h" #include "GeneralUtils.h" #include "User.h" @@ -14,11 +13,11 @@ #include "dZoneManager.h" #include "CharacterComponent.h" #include "ZCompression.h" - +#include "eConnectionType.h" void WorldPackets::SendLoadStaticZone(const SystemAddress& sysAddr, float x, float y, float z, uint32_t checksum) { RakNet::BitStream bitStream; - PacketUtils::WriteHeader(bitStream, CLIENT, MSG_CLIENT_LOAD_STATIC_ZONE); + PacketUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::LOAD_STATIC_ZONE); auto zone = dZoneManager::Instance()->GetZone()->GetZoneID(); bitStream.Write(static_cast(zone.GetMapID())); @@ -42,7 +41,7 @@ void WorldPackets::SendCharacterList(const SystemAddress& sysAddr, User* user) { if (!user) return; RakNet::BitStream bitStream; - PacketUtils::WriteHeader(bitStream, CLIENT, MSG_CLIENT_CHARACTER_LIST_RESPONSE); + PacketUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::CHARACTER_LIST_RESPONSE); std::vector characters = user->GetCharacters(); bitStream.Write(static_cast(characters.size())); @@ -89,30 +88,30 @@ void WorldPackets::SendCharacterList(const SystemAddress& sysAddr, User* user) { SEND_PACKET; } -void WorldPackets::SendCharacterCreationResponse(const SystemAddress& sysAddr, eCreationResponse response) { +void WorldPackets::SendCharacterCreationResponse(const SystemAddress& sysAddr, eCharacterCreationResponse response) { RakNet::BitStream bitStream; - PacketUtils::WriteHeader(bitStream, CLIENT, MSG_CLIENT_CHARACTER_CREATE_RESPONSE); + PacketUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::CHARACTER_CREATE_RESPONSE); bitStream.Write(response); SEND_PACKET; } void WorldPackets::SendCharacterRenameResponse(const SystemAddress& sysAddr, eRenameResponse response) { RakNet::BitStream bitStream; - PacketUtils::WriteHeader(bitStream, CLIENT, MSG_CLIENT_CHARACTER_RENAME_RESPONSE); + PacketUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::CHARACTER_RENAME_RESPONSE); bitStream.Write(response); SEND_PACKET; } void WorldPackets::SendCharacterDeleteResponse(const SystemAddress& sysAddr, bool response) { RakNet::BitStream bitStream; - PacketUtils::WriteHeader(bitStream, CLIENT, MSG_CLIENT_DELETE_CHARACTER_RESPONSE); + PacketUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::DELETE_CHARACTER_RESPONSE); bitStream.Write(static_cast(response)); SEND_PACKET; } void WorldPackets::SendTransferToWorld(const SystemAddress& sysAddr, const std::string& serverIP, uint32_t serverPort, bool mythranShift) { RakNet::BitStream bitStream; - PacketUtils::WriteHeader(bitStream, CLIENT, MSG_CLIENT_TRANSFER_TO_WORLD); + PacketUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::TRANSFER_TO_WORLD); PacketUtils::WriteString(bitStream, serverIP, 33); bitStream.Write(static_cast(serverPort)); @@ -123,14 +122,14 @@ void WorldPackets::SendTransferToWorld(const SystemAddress& sysAddr, const std:: void WorldPackets::SendServerState(const SystemAddress& sysAddr) { RakNet::BitStream bitStream; - PacketUtils::WriteHeader(bitStream, CLIENT, MSG_CLIENT_SERVER_STATES); + PacketUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::SERVER_STATES); bitStream.Write(static_cast(1)); //If the server is receiving this request, it probably is ready anyway. SEND_PACKET; } void WorldPackets::SendCreateCharacter(const SystemAddress& sysAddr, Entity* entity, const std::string& xmlData, const std::u16string& username, eGameMasterLevel gm) { RakNet::BitStream bitStream; - PacketUtils::WriteHeader(bitStream, CLIENT, MSG_CLIENT_CREATE_CHARACTER); + PacketUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::CREATE_CHARACTER); RakNet::BitStream data; data.Write(7); //LDF key count @@ -199,7 +198,7 @@ void WorldPackets::SendCreateCharacter(const SystemAddress& sysAddr, Entity* ent void WorldPackets::SendChatModerationResponse(const SystemAddress& sysAddr, bool requestAccepted, uint32_t requestID, const std::string& receiver, std::vector> unacceptedItems) { CBITSTREAM; - PacketUtils::WriteHeader(bitStream, CLIENT, MSG_CLIENT_CHAT_MODERATION_STRING); + PacketUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::CHAT_MODERATION_STRING); bitStream.Write(unacceptedItems.empty()); // Is sentence ok? bitStream.Write(0x16); // Source ID, unknown @@ -223,7 +222,7 @@ void WorldPackets::SendChatModerationResponse(const SystemAddress& sysAddr, bool void WorldPackets::SendGMLevelChange(const SystemAddress& sysAddr, bool success, eGameMasterLevel highestLevel, eGameMasterLevel prevLevel, eGameMasterLevel newLevel) { CBITSTREAM; - PacketUtils::WriteHeader(bitStream, CLIENT, MSG_CLIENT_MAKE_GM_RESPONSE); + PacketUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::MAKE_GM_RESPONSE); bitStream.Write(success); bitStream.Write(static_cast(highestLevel)); diff --git a/dNet/WorldPackets.h b/dNet/WorldPackets.h index ec20ac22..ea8186c7 100644 --- a/dNet/WorldPackets.h +++ b/dNet/WorldPackets.h @@ -9,11 +9,13 @@ class User; struct SystemAddress; enum class eGameMasterLevel : uint8_t; +enum class eCharacterCreationResponse : uint8_t; +enum class eRenameResponse : uint8_t; namespace WorldPackets { void SendLoadStaticZone(const SystemAddress& sysAddr, float x, float y, float z, uint32_t checksum); void SendCharacterList(const SystemAddress& sysAddr, User* user); - void SendCharacterCreationResponse(const SystemAddress& sysAddr, eCreationResponse response); + void SendCharacterCreationResponse(const SystemAddress& sysAddr, eCharacterCreationResponse response); void SendCharacterRenameResponse(const SystemAddress& sysAddr, eRenameResponse response); void SendCharacterDeleteResponse(const SystemAddress& sysAddr, bool response); void SendTransferToWorld(const SystemAddress& sysAddr, const std::string& serverIP, uint32_t serverPort, bool mythranShift); diff --git a/dNet/dServer.cpp b/dNet/dServer.cpp index c91c7508..610f06a5 100644 --- a/dNet/dServer.cpp +++ b/dNet/dServer.cpp @@ -6,9 +6,11 @@ #include "RakNetworkFactory.h" #include "MessageIdentifiers.h" +#include "eConnectionType.h" +#include "eServerMessageType.h" +#include "eMasterMessageType.h" #include "PacketUtils.h" -#include "dMessageIdentifiers.h" #include "MasterPackets.h" #include "ZoneInstanceManager.h" @@ -118,14 +120,14 @@ Packet* dServer::ReceiveFromMaster() { } if (packet->data[0] == ID_USER_PACKET_ENUM) { - if (packet->data[1] == MASTER) { - switch (packet->data[3]) { - case MSG_MASTER_REQUEST_ZONE_TRANSFER_RESPONSE: { + if (static_cast(packet->data[1]) == eConnectionType::MASTER) { + switch (static_cast(packet->data[3])) { + case eMasterMessageType::REQUEST_ZONE_TRANSFER_RESPONSE: { uint64_t requestID = PacketUtils::ReadPacketU64(8, packet); ZoneInstanceManager::Instance()->HandleRequestZoneTransferResponse(requestID, packet); break; } - case MSG_MASTER_SHUTDOWN: + case eMasterMessageType::SHUTDOWN: *mShouldShutdown = true; break; @@ -166,7 +168,7 @@ void dServer::SendToMaster(RakNet::BitStream* bitStream) { void dServer::Disconnect(const SystemAddress& sysAddr, eServerDisconnectIdentifiers disconNotifyID) { RakNet::BitStream bitStream; - PacketUtils::WriteHeader(bitStream, SERVER, MSG_SERVER_DISCONNECT_NOTIFY); + PacketUtils::WriteHeader(bitStream, eConnectionType::SERVER, eServerMessageType::DISCONNECT_NOTIFY); bitStream.Write(disconNotifyID); mPeer->Send(&bitStream, SYSTEM_PRIORITY, RELIABLE_ORDERED, 0, sysAddr, false); diff --git a/dPhysics/dpGrid.cpp b/dPhysics/dpGrid.cpp index b4fe385e..1631c91a 100644 --- a/dPhysics/dpGrid.cpp +++ b/dPhysics/dpGrid.cpp @@ -63,13 +63,13 @@ void dpGrid::Move(dpEntity* entity, float x, float z) { if (cellX < 0) cellX = 0; if (cellZ < 0) cellZ = 0; - if (cellX > NUM_CELLS) cellX = NUM_CELLS; - if (cellZ > NUM_CELLS) cellZ = NUM_CELLS; + if (cellX >= NUM_CELLS) cellX = NUM_CELLS - 1; + if (cellZ >= NUM_CELLS) cellZ = NUM_CELLS - 1; if (oldCellX < 0) oldCellX = 0; if (oldCellZ < 0) oldCellZ = 0; - if (oldCellX > NUM_CELLS) oldCellX = NUM_CELLS; - if (oldCellZ > NUM_CELLS) oldCellZ = NUM_CELLS; + if (oldCellX >= NUM_CELLS) oldCellX = NUM_CELLS - 1; + if (oldCellZ >= NUM_CELLS) oldCellZ = NUM_CELLS - 1; if (oldCellX == cellX && oldCellZ == cellZ) return; diff --git a/dScripts/02_server/Enemy/AG/BossSpiderQueenEnemyServer.cpp b/dScripts/02_server/Enemy/AG/BossSpiderQueenEnemyServer.cpp index aa04f571..a51af03a 100644 --- a/dScripts/02_server/Enemy/AG/BossSpiderQueenEnemyServer.cpp +++ b/dScripts/02_server/Enemy/AG/BossSpiderQueenEnemyServer.cpp @@ -49,8 +49,6 @@ void BossSpiderQueenEnemyServer::OnStartup(Entity* self) { m_CurrentBossStage = 1; // Obtain faction and collision group to save for subsequent resets - //self : SetVar("SBFactionList", self:GetFaction().factionList) - //self : SetVar("SBCollisionGroup", self:GetCollisionGroup().colGroup) } void BossSpiderQueenEnemyServer::OnDie(Entity* self, Entity* killer) { @@ -62,8 +60,6 @@ void BossSpiderQueenEnemyServer::OnDie(Entity* self, Entity* killer) { missionComponent->CompleteMission(instanceMissionID); } - Game::logger->Log("BossSpiderQueenEnemyServer", "Starting timer..."); - // There is suppose to be a 0.1 second delay here but that may be admitted? auto* controller = EntityManager::Instance()->GetZoneControlEntity(); @@ -166,9 +162,6 @@ void BossSpiderQueenEnemyServer::SpawnSpiderWave(Entity* self, int spiderCount) // The Spider Queen Boss is withdrawing and requesting the spawn // of a hatchling wave - /*auto SpiderEggNetworkID = self->GetI64(u"SpiderEggNetworkID"); - if (SpiderEggNetworkID == 0) return;*/ - // Clamp invalid Spiderling number requests to the maximum amount of eggs available if ((spiderCount > maxSpiderEggCnt) || (spiderCount < 0)) spiderCount = maxSpiderEggCnt; @@ -177,44 +170,13 @@ void BossSpiderQueenEnemyServer::SpawnSpiderWave(Entity* self, int spiderCount) hatchCounter = spiderCount; hatchList = {}; - Game::logger->Log("SpiderQueen", "Trying to spawn %i spiders", hatchCounter); - - // Run the wave manager SpiderWaveManager(self); - } void BossSpiderQueenEnemyServer::SpiderWaveManager(Entity* self) { auto SpiderEggNetworkID = self->GetI64(u"SpiderEggNetworkID"); - // Reset the spider egg spawner network to ensure a maximum number of eggs - //SpiderEggNetworkID:SpawnerReset() - - // Obtain a list of all the eggs on the egg spawner network - - //auto spiderEggList = SpiderEggNetworkID:SpawnerGetAllObjectIDsSpawned().objects; - - //if (table.maxn(spiderEggList) <= 0) { - // self->AddTimer("PollSpiderWaveManager", 1.0f); - // return; - //} - // - //// A check for (wave mangement across multiple spawn iterations - //if(hatchCounter < spiderWaveCnt) { - // // We have already prepped some objects for (hatching, - // // remove them from our list for (random egg pulls - // for (i, sVal in ipairs(spiderEggList) { - // if(hatchList[sVal:GetID()]) { - // // We have found a prepped egg, remove it from the spiderEggList - // spiderEggList[i] = nil - // } - // } - - //} - - - std::vector spiderEggs{}; auto spooders = EntityManager::Instance()->GetEntitiesInGroup("EGG"); @@ -224,44 +186,43 @@ void BossSpiderQueenEnemyServer::SpiderWaveManager(Entity* self) { // Select a number of random spider eggs from the list equal to the // current number needed to complete the current wave - for (int i = 0; i < hatchCounter; i++) { - // Select a random spider egg - auto randomEggLoc = GeneralUtils::GenerateRandomNumber(0, spiderEggs.size() - 1); - auto randomEgg = spiderEggs[randomEggLoc]; + if (!spiderEggs.empty()) { + for (int i = 0; i < hatchCounter; i++) { + // Select a random spider egg + auto randomEggLoc = GeneralUtils::GenerateRandomNumber(0, spiderEggs.size() - 1); + auto randomEgg = spiderEggs[randomEggLoc]; - //Just a quick check to try and prevent dupes: - for (auto en : hatchList) { - if (en == randomEgg) { - randomEggLoc++; - randomEgg = spiderEggs[randomEggLoc]; - } - } - - if (randomEgg) { - auto* eggEntity = EntityManager::Instance()->GetEntity(randomEgg); - - if (eggEntity == nullptr) { - continue; + //Just a quick check to try and prevent dupes: + for (auto en : hatchList) { + if (en == randomEgg) { + randomEggLoc++; + randomEgg = spiderEggs[randomEggLoc]; + } } - // Prep the selected spider egg - //randomEgg:FireEvent{s}erID=self, args="prepEgg"} - eggEntity->OnFireEventServerSide(self, "prepEgg"); - Game::logger->Log("SpiderQueen", "Prepping egg %llu", eggEntity->GetObjectID()); + if (randomEgg) { + auto* eggEntity = EntityManager::Instance()->GetEntity(randomEgg); - // Add the prepped egg to our hatchList - hatchList.push_back(eggEntity->GetObjectID()); + if (eggEntity == nullptr) { + continue; + } - // Decrement the hatchCounter - hatchCounter = hatchCounter - 1; - } + // Prep the selected spider egg + eggEntity->OnFireEventServerSide(self, "prepEgg"); - // Remove it from our spider egg list - //table.remove(spiderEggList, randomEggLoc); - spiderEggs[randomEggLoc] = LWOOBJID_EMPTY; + // Add the prepped egg to our hatchList + hatchList.push_back(eggEntity->GetObjectID()); - if (spiderEggs.size() <= 0 || (hatchCounter <= 0)) { - break; + // Decrement the hatchCounter + hatchCounter = hatchCounter - 1; + } + + // Remove it from our spider egg list + spiderEggs[randomEggLoc] = LWOOBJID_EMPTY; + + if (spiderEggs.size() <= 0 || (hatchCounter <= 0)) { + break; + } } } @@ -280,14 +241,12 @@ void BossSpiderQueenEnemyServer::SpiderWaveManager(Entity* self) { } eggEntity->OnFireEventServerSide(self, "hatchEgg"); - Game::logger->Log("SpiderQueen", "hatching egg %llu", eggEntity->GetObjectID()); auto time = PlayAnimAndReturnTime(self, spiderWithdrawIdle); combat->SetStunImmune(false); combat->Stun(time += 6.0f); combat->SetStunImmune(true); - //self->AddTimer("disableWaitForIdle", defaultAnimPause); self->AddTimer("checkForSpiders", 6.0f); } @@ -398,10 +357,6 @@ void BossSpiderQueenEnemyServer::RapidFireShooterManager(Entity* self) { } void BossSpiderQueenEnemyServer::RunRapidFireShooter(Entity* self) { - /* - const auto targets = EntityManager::Instance()->GetEntitiesByComponent(eReplicaComponentType::CHARACTER); - */ - const auto targets = self->GetTargetsInPhantom(); if (self->GetBoolean(u"stoppedFlag")) { @@ -434,8 +389,6 @@ void BossSpiderQueenEnemyServer::RunRapidFireShooter(Entity* self) { PlayAnimAndReturnTime(self, spiderSingleShot); - Game::logger->Log("BossSpiderQueenEnemyServer", "Ran RFS"); - self->AddTimer("RFS", GeneralUtils::GenerateRandomNumber(10, 15)); } @@ -557,26 +510,6 @@ void BossSpiderQueenEnemyServer::OnTimerDone(Entity* self, const std::string tim GameMessages::SendPlayEmbeddedEffectOnAllClientsNearObject(self, u"camshake-bridge", self->GetObjectID(), 100.0f); } else if (timerName == "AdvanceComplete") { - //Reset faction and collision - /*local SBFactionList = self:GetVar("SBFactionList") - local SBCollisionGroup = self:GetVar("SBCollisionGroup") - - for i, fVal in ipairs(SBFactionList) { - if(i == 1) { - //Our first faction - flush and add - self:SetFaction{faction = fVal} - else - //Add - self:ModifyFaction{factionID = fVal, bAddFaction = true} - } - }*/ - - /* - auto SBCollisionGroup = self->GetI32(u"SBCollisionGroup"); - - GameMessages::SendNotifyClientObject(self->GetObjectID(), u"SetColGroup", SBCollisionGroup, 0, LWOOBJID_EMPTY, "", UNASSIGNED_SYSTEM_ADDRESS); - */ - GameMessages::SendNotifyClientObject(self->GetObjectID(), u"SetColGroup", 11, 0, 0, "", UNASSIGNED_SYSTEM_ADDRESS); //Wind up, telegraphing next round @@ -626,7 +559,6 @@ void BossSpiderQueenEnemyServer::OnTimerDone(Entity* self, const std::string tim //Did we queue a spcial attack? if (self->GetBoolean(u"bSpecialQueued")) { self->SetBoolean(u"bSpecialQueued", false); - //SpiderSkillManager(self, true); } } } @@ -674,17 +606,6 @@ void BossSpiderQueenEnemyServer::OnUpdate(Entity* self) { controllable->SetStatic(true); EntityManager::Instance()->SerializeEntity(self); - - //if (waitForIdle) return; - - ////Play the Spider Boss' mountain idle anim - //PlayAnimAndReturnTime(self, spiderWithdrawIdle); - - ////If there are still baby spiders, don't do anyhting either - //auto spooders = EntityManager::Instance()->GetEntitiesInGroup("BabySpider"); - //if (spooders.size() > 0) return; - //else - // WithdrawSpider(self, false); } //---------------------------------------------- diff --git a/dScripts/02_server/Enemy/General/BaseEnemyApe.cpp b/dScripts/02_server/Enemy/General/BaseEnemyApe.cpp index 50108ffb..19a6490a 100644 --- a/dScripts/02_server/Enemy/General/BaseEnemyApe.cpp +++ b/dScripts/02_server/Enemy/General/BaseEnemyApe.cpp @@ -7,6 +7,7 @@ #include "SkillComponent.h" #include "eAninmationFlags.h" #include "RenderComponent.h" +#include "eStateChangeType.h" void BaseEnemyApe::OnStartup(Entity* self) { self->SetVar(u"timesStunned", 2); @@ -16,7 +17,7 @@ void BaseEnemyApe::OnStartup(Entity* self) { void BaseEnemyApe::OnDie(Entity* self, Entity* killer) { auto* anchor = EntityManager::Instance()->GetEntity(self->GetVar(u"QB")); if (anchor != nullptr && !anchor->GetIsDead()) { - anchor->Smash(self->GetObjectID(), SILENT); + anchor->Smash(self->GetObjectID(), eKillType::SILENT); } } diff --git a/dScripts/02_server/Equipment/BootyDigServer.cpp b/dScripts/02_server/Equipment/BootyDigServer.cpp index 375bc4e5..190c232b 100644 --- a/dScripts/02_server/Equipment/BootyDigServer.cpp +++ b/dScripts/02_server/Equipment/BootyDigServer.cpp @@ -30,7 +30,7 @@ BootyDigServer::OnFireEventServerSide(Entity* self, Entity* sender, std::string return; if (args == "ChestReady" && (propertyOwner == std::to_string(LWOOBJID_EMPTY) || player->GetVar(u"bootyDug"))) { - self->Smash(self->GetObjectID(), SILENT); + self->Smash(self->GetObjectID(), eKillType::SILENT); } else if (args == "ChestOpened") { // Make sure players only dig up one booty per instance player->SetVar(u"bootyDug", true); @@ -49,6 +49,6 @@ BootyDigServer::OnFireEventServerSide(Entity* self, Entity* sender, std::string } } } else if (args == "ChestDead") { - self->Smash(player->GetObjectID(), SILENT); + self->Smash(player->GetObjectID(), eKillType::SILENT); } } diff --git a/dScripts/02_server/Map/AG/AgCagedBricksServer.cpp b/dScripts/02_server/Map/AG/AgCagedBricksServer.cpp index 3c400e5d..13c9c04b 100644 --- a/dScripts/02_server/Map/AG/AgCagedBricksServer.cpp +++ b/dScripts/02_server/Map/AG/AgCagedBricksServer.cpp @@ -4,6 +4,7 @@ #include "Character.h" #include "EntityManager.h" #include "eReplicaComponentType.h" +#include "ePlayerFlag.h" void AgCagedBricksServer::OnUse(Entity* self, Entity* user) { //Tell the client to spawn the baby spiderling: @@ -17,7 +18,7 @@ void AgCagedBricksServer::OnUse(Entity* self, Entity* user) { if (!character) return; - character->SetPlayerFlag(74, true); + character->SetPlayerFlag(ePlayerFlag::CAGED_SPIDER, true); //Remove the maelstrom cube: auto inv = static_cast(user->GetComponent(eReplicaComponentType::INVENTORY)); diff --git a/dScripts/02_server/Map/AG/NpcCowboyServer.cpp b/dScripts/02_server/Map/AG/NpcCowboyServer.cpp index c5a0e8f9..6dd212a4 100644 --- a/dScripts/02_server/Map/AG/NpcCowboyServer.cpp +++ b/dScripts/02_server/Map/AG/NpcCowboyServer.cpp @@ -18,7 +18,7 @@ void NpcCowboyServer::OnMissionDialogueOK(Entity* self, Entity* target, int miss missionState == eMissionState::AVAILABLE || missionState == eMissionState::COMPLETE_AVAILABLE) { if (inventoryComponent->GetLotCount(14378) == 0) { - inventoryComponent->AddItem(14378, 1, eLootSourceType::LOOT_SOURCE_NONE); + inventoryComponent->AddItem(14378, 1, eLootSourceType::NONE); } } else if (missionState == eMissionState::READY_TO_COMPLETE || missionState == eMissionState::COMPLETE_READY_TO_COMPLETE) { inventoryComponent->RemoveItem(14378, 1); diff --git a/dScripts/02_server/Map/AG/NpcPirateServer.cpp b/dScripts/02_server/Map/AG/NpcPirateServer.cpp index 6e7e696c..cad0d64c 100644 --- a/dScripts/02_server/Map/AG/NpcPirateServer.cpp +++ b/dScripts/02_server/Map/AG/NpcPirateServer.cpp @@ -10,7 +10,7 @@ void NpcPirateServer::OnMissionDialogueOK(Entity* self, Entity* target, int miss // Add or remove the lucky shovel based on whether the mission was completed or started if ((missionState == eMissionState::AVAILABLE || missionState == eMissionState::COMPLETE_AVAILABLE) && luckyShovel == nullptr) { - inventory->AddItem(14591, 1, eLootSourceType::LOOT_SOURCE_NONE); + inventory->AddItem(14591, 1, eLootSourceType::NONE); } else if (missionState == eMissionState::READY_TO_COMPLETE || missionState == eMissionState::COMPLETE_READY_TO_COMPLETE) { inventory->RemoveItem(14591, 1); } diff --git a/dScripts/02_server/Map/AG/NpcWispServer.cpp b/dScripts/02_server/Map/AG/NpcWispServer.cpp index 99345973..84196c8c 100644 --- a/dScripts/02_server/Map/AG/NpcWispServer.cpp +++ b/dScripts/02_server/Map/AG/NpcWispServer.cpp @@ -19,7 +19,7 @@ void NpcWispServer::OnMissionDialogueOK(Entity* self, Entity* target, int missio // For the daily we add the maelstrom vacuum if the player doesn't have it yet if (missionID == 1883 && (missionState == eMissionState::AVAILABLE || missionState == eMissionState::COMPLETE_AVAILABLE) && maelstromVacuum == nullptr) { - inventory->AddItem(maelstromVacuumLot, 1, eLootSourceType::LOOT_SOURCE_NONE); + inventory->AddItem(maelstromVacuumLot, 1, eLootSourceType::NONE); } else if (missionState == eMissionState::READY_TO_COMPLETE || missionState == eMissionState::COMPLETE_READY_TO_COMPLETE) { inventory->RemoveItem(maelstromVacuumLot, 1); } diff --git a/dScripts/02_server/Map/AG/RemoveRentalGear.cpp b/dScripts/02_server/Map/AG/RemoveRentalGear.cpp index 18177e57..f9bdf1ce 100644 --- a/dScripts/02_server/Map/AG/RemoveRentalGear.cpp +++ b/dScripts/02_server/Map/AG/RemoveRentalGear.cpp @@ -4,6 +4,7 @@ #include "eMissionState.h" #include "Character.h" #include "eReplicaComponentType.h" +#include "ePlayerFlag.h" /* -------------------------------------------------------------- @@ -36,6 +37,6 @@ void RemoveRentalGear::OnMissionDialogueOK(Entity* self, Entity* target, int mis //reset the equipment flag auto character = target->GetCharacter(); - if (character) character->SetPlayerFlag(equipFlag, false); + if (character) character->SetPlayerFlag(ePlayerFlag::EQUPPED_TRIAL_FACTION_GEAR, false); } } diff --git a/dScripts/02_server/Map/AG/RemoveRentalGear.h b/dScripts/02_server/Map/AG/RemoveRentalGear.h index cc33b5f6..cf9002d7 100644 --- a/dScripts/02_server/Map/AG/RemoveRentalGear.h +++ b/dScripts/02_server/Map/AG/RemoveRentalGear.h @@ -7,6 +7,5 @@ class RemoveRentalGear : public CppScripts::Script { private: int defaultMission = 768; //mission to remove gearSets on completion std::vector gearSets = { 14359,14321,14353,14315 }; //inventory items to remove - int equipFlag = 126; //Set upon wearing trial faction armor for the first time in a session }; diff --git a/dScripts/02_server/Map/AG_Spider_Queen/ZoneAgSpiderQueen.cpp b/dScripts/02_server/Map/AG_Spider_Queen/ZoneAgSpiderQueen.cpp index 5996548f..2711b179 100644 --- a/dScripts/02_server/Map/AG_Spider_Queen/ZoneAgSpiderQueen.cpp +++ b/dScripts/02_server/Map/AG_Spider_Queen/ZoneAgSpiderQueen.cpp @@ -9,8 +9,8 @@ void ZoneAgSpiderQueen::SetGameVariables(Entity* self) { ZoneAgProperty::SetGameVariables(self); // Disable property flags - self->SetVar(defeatedProperyFlag, 0); - self->SetVar(placedModelFlag, 0); + self->SetVar(defeatedProperyFlag, 0); + self->SetVar(placedModelFlag, 0); self->SetVar(guardFirstMissionFlag, 0); self->SetVar(guardMissionFlag, 0); self->SetVar(brickLinkMissionIDFlag, 0); diff --git a/dScripts/02_server/Map/AM/AmBlueX.cpp b/dScripts/02_server/Map/AM/AmBlueX.cpp index 8e32694c..312cdc47 100644 --- a/dScripts/02_server/Map/AM/AmBlueX.cpp +++ b/dScripts/02_server/Map/AM/AmBlueX.cpp @@ -18,7 +18,7 @@ void AmBlueX::OnSkillEventFired(Entity* self, Entity* caster, const std::string& auto* character = caster->GetCharacter(); if (character != nullptr) { - character->SetPlayerFlag(self->GetVar(m_FlagVariable), true); + character->SetPlayerFlag(self->GetVar(m_FlagVariable), true); } EntityInfo info{}; diff --git a/dScripts/02_server/Map/AM/AmBridge.cpp b/dScripts/02_server/Map/AM/AmBridge.cpp index 88f30642..719ca058 100644 --- a/dScripts/02_server/Map/AM/AmBridge.cpp +++ b/dScripts/02_server/Map/AM/AmBridge.cpp @@ -24,5 +24,5 @@ void AmBridge::OnTimerDone(Entity* self, std::string timerName) { return; } - self->Smash(self->GetObjectID(), VIOLENT); + self->Smash(self->GetObjectID(), eKillType::VIOLENT); } diff --git a/dScripts/02_server/Map/AM/AmConsoleTeleportServer.cpp b/dScripts/02_server/Map/AM/AmConsoleTeleportServer.cpp index f3931e0d..0627b27a 100644 --- a/dScripts/02_server/Map/AM/AmConsoleTeleportServer.cpp +++ b/dScripts/02_server/Map/AM/AmConsoleTeleportServer.cpp @@ -1,6 +1,6 @@ #include "AmConsoleTeleportServer.h" #include "ChooseYourDestinationNsToNt.h" -#include "AMFFormat.h" +#include "Amf3.h" void AmConsoleTeleportServer::OnStartup(Entity* self) { self->SetVar(u"teleportAnim", m_TeleportAnim); diff --git a/dScripts/02_server/Map/AM/AmDrawBridge.cpp b/dScripts/02_server/Map/AM/AmDrawBridge.cpp index 20636b13..3c4dcce6 100644 --- a/dScripts/02_server/Map/AM/AmDrawBridge.cpp +++ b/dScripts/02_server/Map/AM/AmDrawBridge.cpp @@ -2,6 +2,7 @@ #include "EntityManager.h" #include "GameMessages.h" #include "SimplePhysicsComponent.h" +#include "eTerminateType.h" void AmDrawBridge::OnStartup(Entity* self) { self->SetNetworkVar(u"InUse", false); @@ -25,7 +26,7 @@ void AmDrawBridge::OnUse(Entity* self, Entity* user) { auto* player = user; - GameMessages::SendTerminateInteraction(player->GetObjectID(), FROM_INTERACTION, self->GetObjectID()); + GameMessages::SendTerminateInteraction(player->GetObjectID(), eTerminateType::FROM_INTERACTION, self->GetObjectID()); } void AmDrawBridge::OnTimerDone(Entity* self, std::string timerName) { diff --git a/dScripts/02_server/Map/AM/AmDropshipComputer.cpp b/dScripts/02_server/Map/AM/AmDropshipComputer.cpp index 15ca7267..f23fa93f 100644 --- a/dScripts/02_server/Map/AM/AmDropshipComputer.cpp +++ b/dScripts/02_server/Map/AM/AmDropshipComputer.cpp @@ -12,7 +12,7 @@ void AmDropshipComputer::OnStartup(Entity* self) { void AmDropshipComputer::OnUse(Entity* self, Entity* user) { auto* rebuildComponent = self->GetComponent(); - if (rebuildComponent == nullptr || rebuildComponent->GetState() != REBUILD_COMPLETED) { + if (rebuildComponent == nullptr || rebuildComponent->GetState() != eRebuildState::COMPLETED) { return; } @@ -27,7 +27,7 @@ void AmDropshipComputer::OnUse(Entity* self, Entity* user) { return; } - inventoryComponent->AddItem(m_NexusTalonDataCard, 1, eLootSourceType::LOOT_SOURCE_NONE); + inventoryComponent->AddItem(m_NexusTalonDataCard, 1, eLootSourceType::NONE); } void AmDropshipComputer::OnDie(Entity* self, Entity* killer) { @@ -76,7 +76,7 @@ void AmDropshipComputer::OnTimerDone(Entity* self, std::string timerName) { return; } - if (timerName == "reset" && rebuildComponent->GetState() == REBUILD_OPEN) { - self->Smash(self->GetObjectID(), SILENT); + if (timerName == "reset" && rebuildComponent->GetState() == eRebuildState::OPEN) { + self->Smash(self->GetObjectID(), eKillType::SILENT); } } diff --git a/dScripts/02_server/Map/AM/AmShieldGeneratorQuickbuild.cpp b/dScripts/02_server/Map/AM/AmShieldGeneratorQuickbuild.cpp index 3188db33..381c13bc 100644 --- a/dScripts/02_server/Map/AM/AmShieldGeneratorQuickbuild.cpp +++ b/dScripts/02_server/Map/AM/AmShieldGeneratorQuickbuild.cpp @@ -176,7 +176,7 @@ void AmShieldGeneratorQuickbuild::BuffPlayers(Entity* self) { void AmShieldGeneratorQuickbuild::EnemyEnteredShield(Entity* self, Entity* intruder) { auto* rebuildComponent = self->GetComponent(); - if (rebuildComponent == nullptr || rebuildComponent->GetState() != REBUILD_COMPLETED) { + if (rebuildComponent == nullptr || rebuildComponent->GetState() != eRebuildState::COMPLETED) { return; } diff --git a/dScripts/02_server/Map/AM/AmSkullkinDrill.cpp b/dScripts/02_server/Map/AM/AmSkullkinDrill.cpp index 4bdf6492..e35c700d 100644 --- a/dScripts/02_server/Map/AM/AmSkullkinDrill.cpp +++ b/dScripts/02_server/Map/AM/AmSkullkinDrill.cpp @@ -6,6 +6,7 @@ #include "MissionComponent.h" #include "EntityInfo.h" #include "RenderComponent.h" +#include "eStateChangeType.h" void AmSkullkinDrill::OnStartup(Entity* self) { self->SetNetworkVar(u"bIsInUse", false); @@ -247,7 +248,7 @@ void AmSkullkinDrill::OnHitOrHealResult(Entity* self, Entity* attacker, int32_t } } - self->Smash(attacker->GetObjectID(), SILENT); + self->Smash(attacker->GetObjectID(), eKillType::SILENT); self->CancelAllTimers(); @@ -265,7 +266,7 @@ void AmSkullkinDrill::OnTimerDone(Entity* self, std::string timerName) { auto* child = EntityManager::Instance()->GetEntity(childID); if (child != nullptr) { - child->Smash(self->GetObjectID(), SILENT); + child->Smash(self->GetObjectID(), eKillType::SILENT); } self->SetNetworkVar(u"bIsInUse", false); diff --git a/dScripts/02_server/Map/AM/AmTeapotServer.cpp b/dScripts/02_server/Map/AM/AmTeapotServer.cpp index 1f47cb1a..93f05326 100644 --- a/dScripts/02_server/Map/AM/AmTeapotServer.cpp +++ b/dScripts/02_server/Map/AM/AmTeapotServer.cpp @@ -2,6 +2,7 @@ #include "InventoryComponent.h" #include "GameMessages.h" #include "Item.h" +#include "eTerminateType.h" void AmTeapotServer::OnUse(Entity* self, Entity* user) { auto* inventoryComponent = user->GetComponent(); @@ -18,5 +19,5 @@ void AmTeapotServer::OnUse(Entity* self, Entity* user) { blueFlowerItem->SetCount(blueFlowerItem->GetCount() - 10); inventoryComponent->AddItem(WU_S_IMAGINATION_TEA, 1); } - GameMessages::SendTerminateInteraction(user->GetObjectID(), FROM_INTERACTION, self->GetObjectID()); + GameMessages::SendTerminateInteraction(user->GetObjectID(), eTerminateType::FROM_INTERACTION, self->GetObjectID()); } diff --git a/dScripts/02_server/Map/FV/ImgBrickConsoleQB.cpp b/dScripts/02_server/Map/FV/ImgBrickConsoleQB.cpp index 9c7b858f..7d86cc73 100644 --- a/dScripts/02_server/Map/FV/ImgBrickConsoleQB.cpp +++ b/dScripts/02_server/Map/FV/ImgBrickConsoleQB.cpp @@ -6,6 +6,7 @@ #include "MissionComponent.h" #include "eMissionState.h" #include "InventoryComponent.h" +#include "eTerminateType.h" int32_t ImgBrickConsoleQB::ResetBricks = 30; int32_t ImgBrickConsoleQB::ResetConsole = 60; @@ -20,7 +21,7 @@ void ImgBrickConsoleQB::OnStartup(Entity* self) { void ImgBrickConsoleQB::OnUse(Entity* self, Entity* user) { auto* rebuildComponent = self->GetComponent(); - if (rebuildComponent->GetState() == REBUILD_COMPLETED) { + if (rebuildComponent->GetState() == eRebuildState::COMPLETED) { if (!self->GetNetworkVar(u"used")) { const auto consoles = EntityManager::Instance()->GetEntitiesInGroup("Console"); @@ -29,7 +30,7 @@ void ImgBrickConsoleQB::OnUse(Entity* self, Entity* user) { for (auto* console : consoles) { auto* consoleRebuildComponent = console->GetComponent(); - if (consoleRebuildComponent->GetState() != REBUILD_COMPLETED) { + if (consoleRebuildComponent->GetState() != eRebuildState::COMPLETED) { continue; } @@ -87,7 +88,7 @@ void ImgBrickConsoleQB::OnUse(Entity* self, Entity* user) { self->SetNetworkVar(u"used", true); - GameMessages::SendTerminateInteraction(player->GetObjectID(), FROM_INTERACTION, self->GetObjectID()); + GameMessages::SendTerminateInteraction(player->GetObjectID(), eTerminateType::FROM_INTERACTION, self->GetObjectID()); } } @@ -113,7 +114,7 @@ void ImgBrickConsoleQB::SmashCanister(Entity* self) { const auto canisters = EntityManager::Instance()->GetEntitiesInGroup("Canister"); for (auto* canister : canisters) { - canister->Smash(canister->GetObjectID(), VIOLENT); + canister->Smash(canister->GetObjectID(), eKillType::VIOLENT); } const auto canister = dZoneManager::Instance()->GetSpawnersByName("BrickCanister"); @@ -146,7 +147,7 @@ void ImgBrickConsoleQB::OnRebuildComplete(Entity* self, Entity* target) { for (auto* console : consoles) { auto* consoleRebuildComponent = console->GetComponent(); - if (consoleRebuildComponent->GetState() != REBUILD_COMPLETED) { + if (consoleRebuildComponent->GetState() != eRebuildState::COMPLETED) { continue; } @@ -167,7 +168,7 @@ void ImgBrickConsoleQB::OnDie(Entity* self, Entity* killer) { auto* rebuildComponent = self->GetComponent(); - if (rebuildComponent->GetState() == REBUILD_COMPLETED) { + if (rebuildComponent->GetState() == eRebuildState::COMPLETED) { auto offFX = 0; const auto location = GeneralUtils::UTF16ToWTF8(self->GetVar(u"console")); @@ -228,14 +229,14 @@ void ImgBrickConsoleQB::OnTimerDone(Entity* self, std::string timerName) { if (timerName == "reset") { auto* rebuildComponent = self->GetComponent(); - if (rebuildComponent->GetState() == REBUILD_OPEN) { - self->Smash(self->GetObjectID(), SILENT); + if (rebuildComponent->GetState() == eRebuildState::OPEN) { + self->Smash(self->GetObjectID(), eKillType::SILENT); } } else if (timerName == "Die") { const auto consoles = EntityManager::Instance()->GetEntitiesInGroup("Console"); for (auto* console : consoles) { - console->Smash(console->GetObjectID(), VIOLENT); + console->Smash(console->GetObjectID(), eKillType::VIOLENT); } } } diff --git a/dScripts/02_server/Map/FV/Racing/RaceMaelstromGeiser.cpp b/dScripts/02_server/Map/FV/Racing/RaceMaelstromGeiser.cpp index b737d449..155be92b 100644 --- a/dScripts/02_server/Map/FV/Racing/RaceMaelstromGeiser.cpp +++ b/dScripts/02_server/Map/FV/Racing/RaceMaelstromGeiser.cpp @@ -55,7 +55,7 @@ void RaceMaelstromGeiser::OnProximityUpdate(Entity* self, Entity* entering, std: } - GameMessages::SendDie(vehicle, self->GetObjectID(), LWOOBJID_EMPTY, true, VIOLENT, u"", 0, 0, 0, true, false, 0); + GameMessages::SendDie(vehicle, self->GetObjectID(), LWOOBJID_EMPTY, true, eKillType::VIOLENT, u"", 0, 0, 0, true, false, 0); auto* zoneController = dZoneManager::Instance()->GetZoneControlObject(); diff --git a/dScripts/02_server/Map/GF/GfCaptainsCannon.cpp b/dScripts/02_server/Map/GF/GfCaptainsCannon.cpp index 2b40db3c..c366d0fb 100644 --- a/dScripts/02_server/Map/GF/GfCaptainsCannon.cpp +++ b/dScripts/02_server/Map/GF/GfCaptainsCannon.cpp @@ -3,6 +3,8 @@ #include "EntityManager.h" #include "MissionComponent.h" #include "RenderComponent.h" +#include "eTerminateType.h" +#include "eStateChangeType.h" void GfCaptainsCannon::OnUse(Entity* self, Entity* user) { if (self->GetVar(u"bIsInUse")) { @@ -79,6 +81,6 @@ void GfCaptainsCannon::OnTimerDone(Entity* self, std::string timerName) { missionComponent->ForceProgress(601, 910, 1); } - GameMessages::SendTerminateInteraction(playerId, FROM_INTERACTION, self->GetObjectID()); + GameMessages::SendTerminateInteraction(playerId, eTerminateType::FROM_INTERACTION, self->GetObjectID()); } } diff --git a/dScripts/02_server/Map/GF/GfTikiTorch.cpp b/dScripts/02_server/Map/GF/GfTikiTorch.cpp index a4f36da2..5d944f0f 100644 --- a/dScripts/02_server/Map/GF/GfTikiTorch.cpp +++ b/dScripts/02_server/Map/GF/GfTikiTorch.cpp @@ -6,6 +6,7 @@ #include "eMissionTaskType.h" #include "eReplicaComponentType.h" #include "RenderComponent.h" +#include "eTerminateType.h" void GfTikiTorch::OnStartup(Entity* self) { LightTorch(self); @@ -34,7 +35,7 @@ void GfTikiTorch::OnTimerDone(Entity* self, std::string timerName) { Entity* player = EntityManager::Instance()->GetEntity(self->GetI64(u"userID")); if (player != nullptr && player->GetCharacter()) { - GameMessages::SendTerminateInteraction(player->GetObjectID(), FROM_INTERACTION, self->GetObjectID()); + GameMessages::SendTerminateInteraction(player->GetObjectID(), eTerminateType::FROM_INTERACTION, self->GetObjectID()); } self->SetBoolean(u"isInUse", false); diff --git a/dScripts/02_server/Map/GF/MastTeleport.cpp b/dScripts/02_server/Map/GF/MastTeleport.cpp index 24d623de..311da34a 100644 --- a/dScripts/02_server/Map/GF/MastTeleport.cpp +++ b/dScripts/02_server/Map/GF/MastTeleport.cpp @@ -4,6 +4,7 @@ #include "Preconditions.h" #include "eEndBehavior.h" #include "DestroyableComponent.h" +#include "eStateChangeType.h" #ifdef _WIN32 #define _USE_MATH_DEFINES @@ -43,10 +44,13 @@ void MastTeleport::OnTimerDone(Entity* self, std::string timerName) { GameMessages::SendTeleport(playerId, position, rotation, player->GetSystemAddress(), true); // Hacky fix for odd rotations - if (self->GetVar(u"MastName") != u"Jail") { + auto mastName = self->GetVar(u"MastName"); + if (mastName == u"Elephant") { GameMessages::SendOrientToAngle(playerId, true, (M_PI / 180) * 140.0f, player->GetSystemAddress()); - } else { + } else if (mastName == u"Jail") { GameMessages::SendOrientToAngle(playerId, true, (M_PI / 180) * 100.0f, player->GetSystemAddress()); + } else if (mastName == u""){ + GameMessages::SendOrientToAngle(playerId, true, (M_PI / 180) * 203.0f, player->GetSystemAddress()); } const auto cinematic = GeneralUtils::UTF16ToWTF8(self->GetVar(u"Cinematic")); diff --git a/dScripts/02_server/Map/General/BankInteractServer.cpp b/dScripts/02_server/Map/General/BankInteractServer.cpp index b96187cf..9b563491 100644 --- a/dScripts/02_server/Map/General/BankInteractServer.cpp +++ b/dScripts/02_server/Map/General/BankInteractServer.cpp @@ -1,24 +1,24 @@ #include "BankInteractServer.h" #include "GameMessages.h" #include "Entity.h" -#include "AMFFormat.h" +#include "Amf3.h" void BankInteractServer::OnUse(Entity* self, Entity* user) { AMFArrayValue args; - AMFStringValue* bank = new AMFStringValue(); - bank->SetStringValue("bank"); - args.InsertValue("state", bank); - GameMessages::SendUIMessageServerToSingleClient(user, user->GetSystemAddress(), "pushGameState", &args); + args.Insert("state", "bank"); + + GameMessages::SendUIMessageServerToSingleClient(user, user->GetSystemAddress(), "pushGameState", args); } void BankInteractServer::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2, int32_t param3) { if (args == "ToggleBank") { AMFArrayValue args; - args.InsertValue("visible", new AMFFalseValue()); - GameMessages::SendUIMessageServerToSingleClient(sender, sender->GetSystemAddress(), "ToggleBank", &args); + args.Insert("visible", false); + + GameMessages::SendUIMessageServerToSingleClient(sender, sender->GetSystemAddress(), "ToggleBank", args); GameMessages::SendNotifyClientObject(self->GetObjectID(), u"CloseBank", 0, 0, LWOOBJID_EMPTY, "", sender->GetSystemAddress()); } diff --git a/dScripts/02_server/Map/General/MailBoxServer.cpp b/dScripts/02_server/Map/General/MailBoxServer.cpp index c2534f3e..53f3b3a2 100644 --- a/dScripts/02_server/Map/General/MailBoxServer.cpp +++ b/dScripts/02_server/Map/General/MailBoxServer.cpp @@ -1,19 +1,20 @@ #include "MailBoxServer.h" -#include "AMFFormat.h" +#include "Amf3.h" #include "GameMessages.h" +#include "Entity.h" void MailBoxServer::OnUse(Entity* self, Entity* user) { - AMFStringValue* value = new AMFStringValue(); - value->SetStringValue("Mail"); AMFArrayValue args; - args.InsertValue("state", value); - GameMessages::SendUIMessageServerToSingleClient(user, user->GetSystemAddress(), "pushGameState", &args); + + args.Insert("state", "Mail"); + + GameMessages::SendUIMessageServerToSingleClient(user, user->GetSystemAddress(), "pushGameState", args); } void MailBoxServer::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2, int32_t param3) { if (args == "toggleMail") { AMFArrayValue args; - args.InsertValue("visible", new AMFFalseValue()); - GameMessages::SendUIMessageServerToSingleClient(sender, sender->GetSystemAddress(), "ToggleMail", &args); + args.Insert("visible", false); + GameMessages::SendUIMessageServerToSingleClient(sender, sender->GetSystemAddress(), "ToggleMail", args); } } diff --git a/dScripts/02_server/Map/General/Ninjago/NjRailActivatorsServer.cpp b/dScripts/02_server/Map/General/Ninjago/NjRailActivatorsServer.cpp index a07de24a..5ca726af 100644 --- a/dScripts/02_server/Map/General/Ninjago/NjRailActivatorsServer.cpp +++ b/dScripts/02_server/Map/General/Ninjago/NjRailActivatorsServer.cpp @@ -7,7 +7,7 @@ void NjRailActivatorsServer::OnUse(Entity* self, Entity* user) { auto* rebuildComponent = self->GetComponent(); // Only allow use if this is not a quick build or the quick build is built - if (rebuildComponent == nullptr || rebuildComponent->GetState() == REBUILD_COMPLETED) { + if (rebuildComponent == nullptr || rebuildComponent->GetState() == eRebuildState::COMPLETED) { auto* character = user->GetCharacter(); if (character != nullptr) { character->SetPlayerFlag(flag, true); diff --git a/dScripts/02_server/Map/General/Ninjago/NjRailPostServer.cpp b/dScripts/02_server/Map/General/Ninjago/NjRailPostServer.cpp index 23389a98..2c435705 100644 --- a/dScripts/02_server/Map/General/Ninjago/NjRailPostServer.cpp +++ b/dScripts/02_server/Map/General/Ninjago/NjRailPostServer.cpp @@ -19,7 +19,7 @@ void NjRailPostServer::OnNotifyObject(Entity* self, Entity* sender, const std::s } void NjRailPostServer::OnRebuildNotifyState(Entity* self, eRebuildState state) { - if (state == REBUILD_COMPLETED) { + if (state == eRebuildState::COMPLETED) { auto* relatedRail = GetRelatedRail(self); if (relatedRail == nullptr) return; @@ -30,7 +30,7 @@ void NjRailPostServer::OnRebuildNotifyState(Entity* self, eRebuildState state) { return; self->SetNetworkVar(NetworkNotActiveVariable, false); - } else if (state == REBUILD_RESETTING) { + } else if (state == eRebuildState::RESETTING) { auto* relatedRail = GetRelatedRail(self); if (relatedRail == nullptr) return; diff --git a/dScripts/02_server/Map/General/Ninjago/NjhubLavaPlayerDeathTrigger.cpp b/dScripts/02_server/Map/General/Ninjago/NjhubLavaPlayerDeathTrigger.cpp index c065f84a..e2b889ef 100644 --- a/dScripts/02_server/Map/General/Ninjago/NjhubLavaPlayerDeathTrigger.cpp +++ b/dScripts/02_server/Map/General/Ninjago/NjhubLavaPlayerDeathTrigger.cpp @@ -5,5 +5,5 @@ void NjhubLavaPlayerDeathTrigger::OnCollisionPhantom(Entity* self, Entity* targe if (!target->IsPlayer()) return; - target->Smash(self->GetObjectID(), VIOLENT, u"drown"); + target->Smash(self->GetObjectID(), eKillType::VIOLENT, u"drown"); } diff --git a/dScripts/02_server/Map/General/PetDigServer.cpp b/dScripts/02_server/Map/General/PetDigServer.cpp index 81d70faf..8c819a8d 100644 --- a/dScripts/02_server/Map/General/PetDigServer.cpp +++ b/dScripts/02_server/Map/General/PetDigServer.cpp @@ -97,7 +97,7 @@ void PetDigServer::OnDie(Entity* self, Entity* killer) { // Handles smashing leftovers (edge case for the AG X) auto* xObject = EntityManager::Instance()->GetEntity(self->GetVar(u"X")); if (xObject != nullptr) { - xObject->Smash(xObject->GetObjectID(), VIOLENT); + xObject->Smash(xObject->GetObjectID(), eKillType::VIOLENT); } } @@ -112,7 +112,7 @@ void PetDigServer::HandleXBuildDig(const Entity* self, Entity* owner, Entity* pe auto* player = playerEntity->GetCharacter(); const auto groupID = self->GetVar(u"groupID"); - auto playerFlag = 0; + int32_t playerFlag = 0; // The flag that the player dug up if (groupID == u"Flag1") { @@ -136,7 +136,7 @@ void PetDigServer::HandleXBuildDig(const Entity* self, Entity* owner, Entity* pe auto* xObject = EntityManager::Instance()->GetEntity(self->GetVar(u"X")); if (xObject != nullptr) { - xObject->Smash(xObject->GetObjectID(), VIOLENT); + xObject->Smash(xObject->GetObjectID(), eKillType::VIOLENT); } } diff --git a/dScripts/02_server/Map/General/PropertyPlatform.cpp b/dScripts/02_server/Map/General/PropertyPlatform.cpp index 902b9646..7016db94 100644 --- a/dScripts/02_server/Map/General/PropertyPlatform.cpp +++ b/dScripts/02_server/Map/General/PropertyPlatform.cpp @@ -15,7 +15,7 @@ void PropertyPlatform::OnRebuildComplete(Entity* self, Entity* target) { void PropertyPlatform::OnUse(Entity* self, Entity* user) { auto* rebuildComponent = self->GetComponent(); - if (rebuildComponent != nullptr && rebuildComponent->GetState() == REBUILD_COMPLETED) { + if (rebuildComponent != nullptr && rebuildComponent->GetState() == eRebuildState::COMPLETED) { // auto* movingPlatform = self->GetComponent(); // if (movingPlatform != nullptr) { // movingPlatform->GotoWaypoint(1); diff --git a/dScripts/02_server/Map/General/StoryBoxInteractServer.cpp b/dScripts/02_server/Map/General/StoryBoxInteractServer.cpp index 2683ddd4..9a1a4908 100644 --- a/dScripts/02_server/Map/General/StoryBoxInteractServer.cpp +++ b/dScripts/02_server/Map/General/StoryBoxInteractServer.cpp @@ -2,7 +2,8 @@ #include "Character.h" #include "GameMessages.h" #include "dServer.h" -#include "AMFFormat.h" +#include "Amf3.h" +#include "Entity.h" void StoryBoxInteractServer::OnUse(Entity* self, Entity* user) { if (self->GetVar(u"hasCustomText")) { @@ -11,24 +12,18 @@ void StoryBoxInteractServer::OnUse(Entity* self, Entity* user) { { AMFArrayValue args; - auto* state = new AMFStringValue(); - state->SetStringValue("Story"); + args.Insert("state", "Story"); - args.InsertValue("state", state); - - GameMessages::SendUIMessageServerToSingleClient(user, user->GetSystemAddress(), "pushGameState", &args); + GameMessages::SendUIMessageServerToSingleClient(user, user->GetSystemAddress(), "pushGameState", args); } user->AddCallbackTimer(0.1f, [user, customText]() { AMFArrayValue args; - auto* text = new AMFStringValue(); - text->SetStringValue(customText); + args.Insert("visible", true); + args.Insert("text", customText); - args.InsertValue("visible", new AMFTrueValue()); - args.InsertValue("text", text); - - GameMessages::SendUIMessageServerToSingleClient(user, user->GetSystemAddress(), "ToggleStoryBox", &args); + GameMessages::SendUIMessageServerToSingleClient(user, user->GetSystemAddress(), "ToggleStoryBox", args); }); return; diff --git a/dScripts/02_server/Map/General/TokenConsoleServer.cpp b/dScripts/02_server/Map/General/TokenConsoleServer.cpp index 5212a9b5..e13011cb 100644 --- a/dScripts/02_server/Map/General/TokenConsoleServer.cpp +++ b/dScripts/02_server/Map/General/TokenConsoleServer.cpp @@ -3,6 +3,8 @@ #include "GameMessages.h" #include "Character.h" #include "eReplicaComponentType.h" +#include "eTerminateType.h" +#include "ePlayerFlag.h" //2021-05-03 - max - added script, omitted some parts related to inheritance in lua which we don't need @@ -22,15 +24,15 @@ void TokenConsoleServer::OnUse(Entity* self, Entity* user) { if (!character) return; // At this point the player has to be in a faction. LOT tokenLOT = 0; - if (character->GetPlayerFlag(ePlayerFlags::VENTURE_FACTION)) //venture + if (character->GetPlayerFlag(ePlayerFlag::VENTURE_FACTION)) //venture tokenLOT = 8321; - else if (character->GetPlayerFlag(ePlayerFlags::ASSEMBLY_FACTION)) //assembly + else if (character->GetPlayerFlag(ePlayerFlag::ASSEMBLY_FACTION)) //assembly tokenLOT = 8318; - else if (character->GetPlayerFlag(ePlayerFlags::PARADOX_FACTION)) //paradox + else if (character->GetPlayerFlag(ePlayerFlag::PARADOX_FACTION)) //paradox tokenLOT = 8320; - else if (character->GetPlayerFlag(ePlayerFlags::SENTINEL_FACTION)) //sentinel + else if (character->GetPlayerFlag(ePlayerFlag::SENTINEL_FACTION)) //sentinel tokenLOT = 8319; - inv->AddItem(tokenLOT, tokensToGive, eLootSourceType::LOOT_SOURCE_NONE); + inv->AddItem(tokenLOT, tokensToGive, eLootSourceType::NONE); } GameMessages::SendTerminateInteraction(user->GetObjectID(), eTerminateType::FROM_INTERACTION, self->GetObjectID()); diff --git a/dScripts/02_server/Map/General/WishingWellServer.cpp b/dScripts/02_server/Map/General/WishingWellServer.cpp index fa3e13e0..58ce1c72 100644 --- a/dScripts/02_server/Map/General/WishingWellServer.cpp +++ b/dScripts/02_server/Map/General/WishingWellServer.cpp @@ -3,6 +3,7 @@ #include "GameMessages.h" #include "Loot.h" #include "EntityManager.h" +#include "eTerminateType.h" void WishingWellServer::OnStartup(Entity* self) { } diff --git a/dScripts/02_server/Map/NS/NsLegoClubDoor.cpp b/dScripts/02_server/Map/NS/NsLegoClubDoor.cpp index 56a213b8..d7ee5fed 100644 --- a/dScripts/02_server/Map/NS/NsLegoClubDoor.cpp +++ b/dScripts/02_server/Map/NS/NsLegoClubDoor.cpp @@ -1,7 +1,7 @@ #include "NsLegoClubDoor.h" #include "dZoneManager.h" #include "GameMessages.h" -#include "AMFFormat.h" +#include "Amf3.h" void NsLegoClubDoor::OnStartup(Entity* self) { self->SetVar(u"currentZone", (int32_t)dZoneManager::Instance()->GetZoneID().GetMapID()); @@ -12,116 +12,56 @@ void NsLegoClubDoor::OnStartup(Entity* self) { args = {}; - AMFStringValue* callbackClient = new AMFStringValue(); - callbackClient->SetStringValue(std::to_string(self->GetObjectID())); - args.InsertValue("callbackClient", callbackClient); + args.Insert("callbackClient", std::to_string(self->GetObjectID())); + args.Insert("strIdentifier", "choiceDoor"); + args.Insert("title", "%[UI_CHOICE_DESTINATION]"); - AMFStringValue* strIdentifier = new AMFStringValue(); - strIdentifier->SetStringValue("choiceDoor"); - args.InsertValue("strIdentifier", strIdentifier); - - AMFStringValue* title = new AMFStringValue(); - title->SetStringValue("%[UI_CHOICE_DESTINATION]"); - args.InsertValue("title", title); - - AMFArrayValue* choiceOptions = new AMFArrayValue(); + AMFArrayValue* choiceOptions = args.InsertArray("options"); { - AMFArrayValue* nsArgs = new AMFArrayValue(); + AMFArrayValue* nsArgs = choiceOptions->PushArray(); - AMFStringValue* image = new AMFStringValue(); - image->SetStringValue("textures/ui/zone_thumnails/Nimbus_Station.dds"); - nsArgs->InsertValue("image", image); - - AMFStringValue* caption = new AMFStringValue(); - caption->SetStringValue("%[UI_CHOICE_NS]"); - nsArgs->InsertValue("caption", caption); - - AMFStringValue* identifier = new AMFStringValue(); - identifier->SetStringValue("zoneID_1200"); - nsArgs->InsertValue("identifier", identifier); - - AMFStringValue* tooltipText = new AMFStringValue(); - tooltipText->SetStringValue("%[UI_CHOICE_NS_HOVER]"); - nsArgs->InsertValue("tooltipText", tooltipText); - - choiceOptions->PushBackValue(nsArgs); + nsArgs->Insert("image", "textures/ui/zone_thumnails/Nimbus_Station.dds"); + nsArgs->Insert("caption", "%[UI_CHOICE_NS]"); + nsArgs->Insert("identifier", "zoneID_1200"); + nsArgs->Insert("tooltipText", "%[UI_CHOICE_NS_HOVER]"); } { - AMFArrayValue* ntArgs = new AMFArrayValue(); + AMFArrayValue* ntArgs = choiceOptions->PushArray(); - AMFStringValue* image = new AMFStringValue(); - image->SetStringValue("textures/ui/zone_thumnails/Nexus_Tower.dds"); - ntArgs->InsertValue("image", image); - - AMFStringValue* caption = new AMFStringValue(); - caption->SetStringValue("%[UI_CHOICE_NT]"); - ntArgs->InsertValue("caption", caption); - - AMFStringValue* identifier = new AMFStringValue(); - identifier->SetStringValue("zoneID_1900"); - ntArgs->InsertValue("identifier", identifier); - - AMFStringValue* tooltipText = new AMFStringValue(); - tooltipText->SetStringValue("%[UI_CHOICE_NT_HOVER]"); - ntArgs->InsertValue("tooltipText", tooltipText); - - choiceOptions->PushBackValue(ntArgs); + ntArgs->Insert("image", "textures/ui/zone_thumnails/Nexus_Tower.dds"); + ntArgs->Insert("caption", "%[UI_CHOICE_NT]"); + ntArgs->Insert("identifier", "zoneID_1900"); + ntArgs->Insert("tooltipText", "%[UI_CHOICE_NT_HOVER]"); } options = choiceOptions; - - args.InsertValue("options", choiceOptions); } void NsLegoClubDoor::OnUse(Entity* self, Entity* user) { auto* player = user; if (CheckChoice(self, player)) { - AMFArrayValue* multiArgs = new AMFArrayValue(); + AMFArrayValue multiArgs; - AMFStringValue* callbackClient = new AMFStringValue(); - callbackClient->SetStringValue(std::to_string(self->GetObjectID())); - multiArgs->InsertValue("callbackClient", callbackClient); - - AMFStringValue* strIdentifier = new AMFStringValue(); - strIdentifier->SetStringValue("choiceDoor"); - multiArgs->InsertValue("strIdentifier", strIdentifier); - - AMFStringValue* title = new AMFStringValue(); - title->SetStringValue("%[UI_CHOICE_DESTINATION]"); - multiArgs->InsertValue("title", title); - - multiArgs->InsertValue("options", options); + multiArgs.Insert("callbackClient", std::to_string(self->GetObjectID())); + multiArgs.Insert("strIdentifier", "choiceDoor"); + multiArgs.Insert("title", "%[UI_CHOICE_DESTINATION]"); + multiArgs.Insert("options", static_cast(options)); GameMessages::SendUIMessageServerToSingleClient(player, player->GetSystemAddress(), "QueueChoiceBox", multiArgs); + + multiArgs.Remove("options", false); // We do not want the local amf to delete the options! } else if (self->GetVar(u"currentZone") != m_ChoiceZoneID) { - AMFArrayValue* multiArgs = new AMFArrayValue(); + AMFArrayValue multiArgs; + multiArgs.Insert("state", "Lobby"); - AMFStringValue* state = new AMFStringValue(); - state->SetStringValue("Lobby"); - multiArgs->InsertValue("state", state); - - AMFArrayValue* context = new AMFArrayValue(); - - AMFStringValue* user = new AMFStringValue(); - user->SetStringValue(std::to_string(player->GetObjectID())); - context->InsertValue("user", user); - - AMFStringValue* callbackObj = new AMFStringValue(); - callbackObj->SetStringValue(std::to_string(self->GetObjectID())); - context->InsertValue("callbackObj", callbackObj); - - AMFStringValue* helpVisible = new AMFStringValue(); - helpVisible->SetStringValue("show"); - context->InsertValue("HelpVisible", helpVisible); - - AMFStringValue* type = new AMFStringValue(); - type->SetStringValue("Lego_Club_Valid"); - context->InsertValue("type", type); - - multiArgs->InsertValue("context", context); + AMFArrayValue* context = multiArgs.InsertArray("context"); + context->Insert("user", std::to_string(player->GetObjectID())); + context->Insert("callbackObj", std::to_string(self->GetObjectID())); + context->Insert("HelpVisible", "show"); + context->Insert("type", "Lego_Club_Valid"); GameMessages::SendUIMessageServerToSingleClient(player, player->GetSystemAddress(), "pushGameState", multiArgs); } else { diff --git a/dScripts/02_server/Map/NS/NsLegoClubDoor.h b/dScripts/02_server/Map/NS/NsLegoClubDoor.h index db1dcae4..5b25ba6d 100644 --- a/dScripts/02_server/Map/NS/NsLegoClubDoor.h +++ b/dScripts/02_server/Map/NS/NsLegoClubDoor.h @@ -2,7 +2,7 @@ #include "CppScripts.h" #include "ChooseYourDestinationNsToNt.h" #include "BaseConsoleTeleportServer.h" -#include "AMFFormat.h" +#include "Amf3.h" class NsLegoClubDoor : public CppScripts::Script, ChooseYourDestinationNsToNt, BaseConsoleTeleportServer { diff --git a/dScripts/02_server/Map/NS/NsLupTeleport.cpp b/dScripts/02_server/Map/NS/NsLupTeleport.cpp index 9cd4359b..74f8ace1 100644 --- a/dScripts/02_server/Map/NS/NsLupTeleport.cpp +++ b/dScripts/02_server/Map/NS/NsLupTeleport.cpp @@ -1,7 +1,7 @@ #include "NsLupTeleport.h" #include "dZoneManager.h" #include "GameMessages.h" -#include "AMFFormat.h" +#include "Amf3.h" void NsLupTeleport::OnStartup(Entity* self) { self->SetVar(u"currentZone", (int32_t)dZoneManager::Instance()->GetZoneID().GetMapID()); @@ -12,72 +12,36 @@ void NsLupTeleport::OnStartup(Entity* self) { args = {}; - AMFStringValue* callbackClient = new AMFStringValue(); - callbackClient->SetStringValue(std::to_string(self->GetObjectID())); - args.InsertValue("callbackClient", callbackClient); + args.Insert("callbackClient", std::to_string(self->GetObjectID())); + args.Insert("strIdentifier", "choiceDoor"); + args.Insert("title", "%[UI_CHOICE_DESTINATION]"); - AMFStringValue* strIdentifier = new AMFStringValue(); - strIdentifier->SetStringValue("choiceDoor"); - args.InsertValue("strIdentifier", strIdentifier); - - AMFStringValue* title = new AMFStringValue(); - title->SetStringValue("%[UI_CHOICE_DESTINATION]"); - args.InsertValue("title", title); - - AMFArrayValue* choiceOptions = new AMFArrayValue(); + AMFArrayValue* choiceOptions = args.InsertArray("options"); { - AMFArrayValue* nsArgs = new AMFArrayValue(); + AMFArrayValue* nsArgs = choiceOptions->PushArray(); - AMFStringValue* image = new AMFStringValue(); - image->SetStringValue("textures/ui/zone_thumnails/Nimbus_Station.dds"); - nsArgs->InsertValue("image", image); - - AMFStringValue* caption = new AMFStringValue(); - caption->SetStringValue("%[UI_CHOICE_NS]"); - nsArgs->InsertValue("caption", caption); - - AMFStringValue* identifier = new AMFStringValue(); - identifier->SetStringValue("zoneID_1200"); - nsArgs->InsertValue("identifier", identifier); - - AMFStringValue* tooltipText = new AMFStringValue(); - tooltipText->SetStringValue("%[UI_CHOICE_NS_HOVER]"); - nsArgs->InsertValue("tooltipText", tooltipText); - - choiceOptions->PushBackValue(nsArgs); + nsArgs->Insert("image", "textures/ui/zone_thumnails/Nimbus_Station.dds"); + nsArgs->Insert("caption", "%[UI_CHOICE_NS]"); + nsArgs->Insert("identifier", "zoneID_1200"); + nsArgs->Insert("tooltipText", "%[UI_CHOICE_NS_HOVER]"); } { - AMFArrayValue* ntArgs = new AMFArrayValue(); + AMFArrayValue* ntArgs = choiceOptions->PushArray(); - AMFStringValue* image = new AMFStringValue(); - image->SetStringValue("textures/ui/zone_thumnails/Nexus_Tower.dds"); - ntArgs->InsertValue("image", image); - - AMFStringValue* caption = new AMFStringValue(); - caption->SetStringValue("%[UI_CHOICE_NT]"); - ntArgs->InsertValue("caption", caption); - - AMFStringValue* identifier = new AMFStringValue(); - identifier->SetStringValue("zoneID_1900"); - ntArgs->InsertValue("identifier", identifier); - - AMFStringValue* tooltipText = new AMFStringValue(); - tooltipText->SetStringValue("%[UI_CHOICE_NT_HOVER]"); - ntArgs->InsertValue("tooltipText", tooltipText); - - choiceOptions->PushBackValue(ntArgs); + ntArgs->Insert("image", "textures/ui/zone_thumnails/Nexus_Tower.dds"); + ntArgs->Insert("caption", "%[UI_CHOICE_NT]"); + ntArgs->Insert("identifier", "zoneID_1900"); + ntArgs->Insert("tooltipText", "%[UI_CHOICE_NT_HOVER]"); } - - args.InsertValue("options", choiceOptions); } void NsLupTeleport::OnUse(Entity* self, Entity* user) { auto* player = user; if (CheckChoice(self, player)) { - GameMessages::SendUIMessageServerToSingleClient(player, player->GetSystemAddress(), "QueueChoiceBox", &args); + GameMessages::SendUIMessageServerToSingleClient(player, player->GetSystemAddress(), "QueueChoiceBox", args); } else { BaseOnUse(self, player); } diff --git a/dScripts/02_server/Map/NS/NsLupTeleport.h b/dScripts/02_server/Map/NS/NsLupTeleport.h index 28bab016..385e92c7 100644 --- a/dScripts/02_server/Map/NS/NsLupTeleport.h +++ b/dScripts/02_server/Map/NS/NsLupTeleport.h @@ -2,7 +2,7 @@ #include "CppScripts.h" #include "ChooseYourDestinationNsToNt.h" #include "BaseConsoleTeleportServer.h" -#include "AMFFormat.h" +#include "Amf3.h" class NsLupTeleport : public CppScripts::Script, ChooseYourDestinationNsToNt, BaseConsoleTeleportServer { diff --git a/dScripts/02_server/Map/NS/NsTokenConsoleServer.cpp b/dScripts/02_server/Map/NS/NsTokenConsoleServer.cpp index a62c165c..326842d2 100644 --- a/dScripts/02_server/Map/NS/NsTokenConsoleServer.cpp +++ b/dScripts/02_server/Map/NS/NsTokenConsoleServer.cpp @@ -4,6 +4,8 @@ #include "Character.h" #include "MissionComponent.h" #include "RebuildComponent.h" +#include "eTerminateType.h" +#include "ePlayerFlag.h" void NsTokenConsoleServer::OnStartup(Entity* self) { @@ -16,7 +18,7 @@ void NsTokenConsoleServer::OnUse(Entity* self, Entity* user) { return; } - if (rebuildComponent->GetState() != REBUILD_COMPLETED) { + if (rebuildComponent->GetState() != eRebuildState::COMPLETED) { return; } @@ -42,20 +44,18 @@ void NsTokenConsoleServer::OnUse(Entity* self, Entity* user) { // Player must be in faction to interact with this entity. LOT tokenLOT = 0; - - if (character->GetPlayerFlag(46)) { + if (character->GetPlayerFlag(ePlayerFlag::VENTURE_FACTION)) //venture tokenLOT = 8321; - } else if (character->GetPlayerFlag(47)) { + else if (character->GetPlayerFlag(ePlayerFlag::ASSEMBLY_FACTION)) //assembly tokenLOT = 8318; - } else if (character->GetPlayerFlag(48)) { + else if (character->GetPlayerFlag(ePlayerFlag::PARADOX_FACTION)) //paradox tokenLOT = 8320; - } else if (character->GetPlayerFlag(49)) { + else if (character->GetPlayerFlag(ePlayerFlag::SENTINEL_FACTION)) //sentinel tokenLOT = 8319; - } - inventoryComponent->AddItem(tokenLOT, 5, eLootSourceType::LOOT_SOURCE_NONE); + inventoryComponent->AddItem(tokenLOT, 5, eLootSourceType::NONE); missionComponent->ForceProgressTaskType(863, 1, 1, false); - GameMessages::SendTerminateInteraction(user->GetObjectID(), FROM_INTERACTION, self->GetObjectID()); + GameMessages::SendTerminateInteraction(user->GetObjectID(), eTerminateType::FROM_INTERACTION, self->GetObjectID()); } diff --git a/dScripts/02_server/Map/NT/NtAssemblyTubeServer.cpp b/dScripts/02_server/Map/NT/NtAssemblyTubeServer.cpp index d5f33336..99bc0de5 100644 --- a/dScripts/02_server/Map/NT/NtAssemblyTubeServer.cpp +++ b/dScripts/02_server/Map/NT/NtAssemblyTubeServer.cpp @@ -6,6 +6,7 @@ #include "eMissionState.h" #include "RenderComponent.h" #include "eEndBehavior.h" +#include "eStateChangeType.h" void NtAssemblyTubeServer::OnStartup(Entity* self) { self->SetProximityRadius(5, "teleport"); diff --git a/dScripts/02_server/Map/NT/NtConsoleTeleportServer.cpp b/dScripts/02_server/Map/NT/NtConsoleTeleportServer.cpp index 324a2fc0..8ba697ce 100644 --- a/dScripts/02_server/Map/NT/NtConsoleTeleportServer.cpp +++ b/dScripts/02_server/Map/NT/NtConsoleTeleportServer.cpp @@ -1,6 +1,6 @@ #include "NtConsoleTeleportServer.h" #include "Entity.h" -#include "AMFFormat.h" +#include "Amf3.h" void NtConsoleTeleportServer::OnStartup(Entity* self) { self->SetVar(u"teleportAnim", m_TeleportAnim); diff --git a/dScripts/02_server/Map/NT/NtDirtCloudServer.cpp b/dScripts/02_server/Map/NT/NtDirtCloudServer.cpp index a9a70c5c..92175dea 100644 --- a/dScripts/02_server/Map/NT/NtDirtCloudServer.cpp +++ b/dScripts/02_server/Map/NT/NtDirtCloudServer.cpp @@ -42,5 +42,5 @@ void NtDirtCloudServer::OnSkillEventFired(Entity* self, Entity* caster, const st self->SetVar(u"CloudOn", false); - self->Smash(self->GetObjectID(), VIOLENT); + self->Smash(self->GetObjectID(), eKillType::VIOLENT); } diff --git a/dScripts/02_server/Map/NT/NtDukeServer.cpp b/dScripts/02_server/Map/NT/NtDukeServer.cpp index d48d50c7..07d17e96 100644 --- a/dScripts/02_server/Map/NT/NtDukeServer.cpp +++ b/dScripts/02_server/Map/NT/NtDukeServer.cpp @@ -2,12 +2,13 @@ #include "InventoryComponent.h" #include "MissionComponent.h" #include "eMissionState.h" +#include "ePlayerFlag.h" void NtDukeServer::SetVariables(Entity* self) { self->SetVar(m_SpyProximityVariable, 35.0f); self->SetVar(m_SpyDataVariable, { - NT_FACTION_SPY_DUKE, 13548, 1319 + ePlayerFlag::NT_FACTION_SPY_DUKE, 13548, 1319 }); self->SetVar>(m_SpyDialogueTableVariable, { @@ -31,7 +32,7 @@ void NtDukeServer::OnMissionDialogueOK(Entity* self, Entity* target, int mission auto lotCount = inventoryComponent->GetLotCount(m_SwordLot); if ((state == eMissionState::AVAILABLE || state == eMissionState::ACTIVE) && lotCount < 1) { - inventoryComponent->AddItem(m_SwordLot, 1, eLootSourceType::LOOT_SOURCE_NONE); + inventoryComponent->AddItem(m_SwordLot, 1, eLootSourceType::NONE); } else if (state == eMissionState::READY_TO_COMPLETE) { inventoryComponent->RemoveItem(m_SwordLot, lotCount); } diff --git a/dScripts/02_server/Map/NT/NtHaelServer.cpp b/dScripts/02_server/Map/NT/NtHaelServer.cpp index fbad421f..c726ae58 100644 --- a/dScripts/02_server/Map/NT/NtHaelServer.cpp +++ b/dScripts/02_server/Map/NT/NtHaelServer.cpp @@ -1,11 +1,12 @@ #include "NtHaelServer.h" #include "Entity.h" +#include "ePlayerFlag.h" void NtHaelServer::SetVariables(Entity* self) { self->SetVar(m_SpyProximityVariable, 25.0f); self->SetVar(m_SpyDataVariable, { - NT_FACTION_SPY_HAEL, 13892, 1321 + ePlayerFlag::NT_FACTION_SPY_HAEL, 13892, 1321 }); self->SetVar>(m_SpyDialogueTableVariable, { diff --git a/dScripts/02_server/Map/NT/NtImagimeterVisibility.cpp b/dScripts/02_server/Map/NT/NtImagimeterVisibility.cpp index c0f9bf51..64493d78 100644 --- a/dScripts/02_server/Map/NT/NtImagimeterVisibility.cpp +++ b/dScripts/02_server/Map/NT/NtImagimeterVisibility.cpp @@ -2,10 +2,11 @@ #include "GameMessages.h" #include "Entity.h" #include "Character.h" +#include "ePlayerFlag.h" void NTImagimeterVisibility::OnRebuildComplete(Entity* self, Entity* target) { auto* character = target->GetCharacter(); - if (character) character->SetPlayerFlag(ePlayerFlags::NT_PLINTH_REBUILD, true); + if (character) character->SetPlayerFlag(ePlayerFlag::NT_PLINTH_REBUILD, true); GameMessages::SendNotifyClientObject(self->GetObjectID(), u"PlinthBuilt", 0, 0, LWOOBJID_EMPTY, "", target->GetSystemAddress()); } diff --git a/dScripts/02_server/Map/NT/NtOverbuildServer.cpp b/dScripts/02_server/Map/NT/NtOverbuildServer.cpp index 8411e55b..f8520d87 100644 --- a/dScripts/02_server/Map/NT/NtOverbuildServer.cpp +++ b/dScripts/02_server/Map/NT/NtOverbuildServer.cpp @@ -1,11 +1,12 @@ #include "NtOverbuildServer.h" #include "EntityManager.h" +#include "ePlayerFlag.h" void NtOverbuildServer::SetVariables(Entity* self) { self->SetVar(m_SpyProximityVariable, 30.0f); self->SetVar(m_SpyDataVariable, { - NT_FACTION_SPY_OVERBUILD, 13891, 1320 + ePlayerFlag::NT_FACTION_SPY_OVERBUILD, 13891, 1320 }); self->SetVar>(m_SpyDialogueTableVariable, { diff --git a/dScripts/02_server/Map/NT/NtParadoxPanelServer.cpp b/dScripts/02_server/Map/NT/NtParadoxPanelServer.cpp index f7e27711..dcae84d2 100644 --- a/dScripts/02_server/Map/NT/NtParadoxPanelServer.cpp +++ b/dScripts/02_server/Map/NT/NtParadoxPanelServer.cpp @@ -5,6 +5,8 @@ #include "Character.h" #include "eMissionState.h" #include "RenderComponent.h" +#include "eTerminateType.h" +#include "eStateChangeType.h" void NtParadoxPanelServer::OnUse(Entity* self, Entity* user) { GameMessages::SendNotifyClientObject(self->GetObjectID(), u"bActive", 1, 0, user->GetObjectID(), "", user->GetSystemAddress()); diff --git a/dScripts/02_server/Map/NT/NtParadoxTeleServer.cpp b/dScripts/02_server/Map/NT/NtParadoxTeleServer.cpp index dc8a195f..687a3477 100644 --- a/dScripts/02_server/Map/NT/NtParadoxTeleServer.cpp +++ b/dScripts/02_server/Map/NT/NtParadoxTeleServer.cpp @@ -4,6 +4,7 @@ #include "MissionComponent.h" #include "eMissionTaskType.h" #include "RenderComponent.h" +#include "eStateChangeType.h" void NtParadoxTeleServer::OnStartup(Entity* self) { self->SetProximityRadius(5, "teleport"); diff --git a/dScripts/02_server/Map/NT/NtVentureCannonServer.cpp b/dScripts/02_server/Map/NT/NtVentureCannonServer.cpp index 1e7b9b3f..976cc24f 100644 --- a/dScripts/02_server/Map/NT/NtVentureCannonServer.cpp +++ b/dScripts/02_server/Map/NT/NtVentureCannonServer.cpp @@ -5,6 +5,8 @@ #include "GeneralUtils.h" #include "RenderComponent.h" #include "eEndBehavior.h" +#include "eTerminateType.h" +#include "eStateChangeType.h" void NtVentureCannonServer::OnUse(Entity* self, Entity* user) { auto* player = user; @@ -102,7 +104,7 @@ void NtVentureCannonServer::UnlockCannonPlayer(Entity* self, Entity* player) { self->SetNetworkVar(u"bIsInUse", false); - GameMessages::SendTerminateInteraction(player->GetObjectID(), FROM_INTERACTION, self->GetObjectID()); + GameMessages::SendTerminateInteraction(player->GetObjectID(), eTerminateType::FROM_INTERACTION, self->GetObjectID()); } void NtVentureCannonServer::FirePlayer(Entity* self, Entity* player) { diff --git a/dScripts/02_server/Map/PR/SpawnGryphonServer.cpp b/dScripts/02_server/Map/PR/SpawnGryphonServer.cpp index 2b7e3904..cf635fe4 100644 --- a/dScripts/02_server/Map/PR/SpawnGryphonServer.cpp +++ b/dScripts/02_server/Map/PR/SpawnGryphonServer.cpp @@ -3,6 +3,7 @@ #include "GameMessages.h" #include "MissionComponent.h" #include "eMissionState.h" +#include "eTerminateType.h" void SpawnGryphonServer::SetVariables(Entity* self) { self->SetVar(u"petLOT", 12433); @@ -20,7 +21,7 @@ void SpawnGryphonServer::OnUse(Entity* self, Entity* user) { if (missionComponent != nullptr && inventoryComponent != nullptr && missionComponent->GetMissionState(1391) == eMissionState::ACTIVE) { inventoryComponent->RemoveItem(12483, inventoryComponent->GetLotCount(12483)); - GameMessages::SendTerminateInteraction(user->GetObjectID(), FROM_INTERACTION, self->GetObjectID()); + GameMessages::SendTerminateInteraction(user->GetObjectID(), eTerminateType::FROM_INTERACTION, self->GetObjectID()); return; } diff --git a/dScripts/02_server/Map/Property/AG_Med/ZoneAgMedProperty.cpp b/dScripts/02_server/Map/Property/AG_Med/ZoneAgMedProperty.cpp index db1c4c4b..46ec7bbd 100644 --- a/dScripts/02_server/Map/Property/AG_Med/ZoneAgMedProperty.cpp +++ b/dScripts/02_server/Map/Property/AG_Med/ZoneAgMedProperty.cpp @@ -31,8 +31,8 @@ void ZoneAgMedProperty::SetGameVariables(Entity* self) { self->SetVar>(AmbientFXSpawner, { "BirdFX", "SunBeam" }); self->SetVar>(BehaviorObjsSpawner, {}); - self->SetVar(defeatedProperyFlag, 118); - self->SetVar(placedModelFlag, 119); + self->SetVar(defeatedProperyFlag, 118); + self->SetVar(placedModelFlag, 119); self->SetVar(guardMissionFlag, 1293); self->SetVar(brickLinkMissionIDFlag, 1294); self->SetVar(passwordFlag, "s3kratK1ttN"); diff --git a/dScripts/02_server/Map/Property/AG_Small/ZoneAgProperty.cpp b/dScripts/02_server/Map/Property/AG_Small/ZoneAgProperty.cpp index 215e22c2..6bf91768 100644 --- a/dScripts/02_server/Map/Property/AG_Small/ZoneAgProperty.cpp +++ b/dScripts/02_server/Map/Property/AG_Small/ZoneAgProperty.cpp @@ -39,8 +39,8 @@ void ZoneAgProperty::SetGameVariables(Entity* self) { self->SetVar(LauncherSpawner, "Launcher"); self->SetVar(InstancerSpawner, "Instancer"); - self->SetVar(defeatedProperyFlag, 71); - self->SetVar(placedModelFlag, 73); + self->SetVar(defeatedProperyFlag, 71); + self->SetVar(placedModelFlag, 73); self->SetVar(guardFirstMissionFlag, 891); self->SetVar(guardMissionFlag, 320); self->SetVar(brickLinkMissionIDFlag, 951); @@ -413,7 +413,7 @@ void ZoneAgProperty::BaseOnFireEventServerSide(Entity* self, Entity* sender, std if (player == nullptr) return; - player->GetCharacter()->SetPlayerFlag(self->GetVar(defeatedProperyFlag), true); + player->GetCharacter()->SetPlayerFlag(self->GetVar(defeatedProperyFlag), true); GameMessages::SendNotifyClientObject(self->GetObjectID(), u"PlayCinematic", 0, 0, LWOOBJID_EMPTY, destroyedCinematic, UNASSIGNED_SYSTEM_ADDRESS); diff --git a/dScripts/02_server/Map/Property/NS_Med/ZoneNsMedProperty.cpp b/dScripts/02_server/Map/Property/NS_Med/ZoneNsMedProperty.cpp index 30e597ee..55bde71c 100644 --- a/dScripts/02_server/Map/Property/NS_Med/ZoneNsMedProperty.cpp +++ b/dScripts/02_server/Map/Property/NS_Med/ZoneNsMedProperty.cpp @@ -29,8 +29,8 @@ void ZoneNsMedProperty::SetGameVariables(Entity* self) { self->SetVar>(AmbientFXSpawner, { "Rockets" }); self->SetVar>(BehaviorObjsSpawner, { }); - self->SetVar(defeatedProperyFlag, 122); - self->SetVar(placedModelFlag, 123); + self->SetVar(defeatedProperyFlag, 122); + self->SetVar(placedModelFlag, 123); self->SetVar(guardMissionFlag, 1322); self->SetVar(brickLinkMissionIDFlag, 1294); self->SetVar(passwordFlag, "s3kratK1ttN"); diff --git a/dScripts/02_server/Map/Property/PropertyBankInteract.cpp b/dScripts/02_server/Map/Property/PropertyBankInteract.cpp index 9e727f39..282dce6c 100644 --- a/dScripts/02_server/Map/Property/PropertyBankInteract.cpp +++ b/dScripts/02_server/Map/Property/PropertyBankInteract.cpp @@ -1,7 +1,8 @@ #include "PropertyBankInteract.h" #include "EntityManager.h" #include "GameMessages.h" -#include "AMFFormat.h" +#include "Amf3.h" +#include "Entity.h" void PropertyBankInteract::OnStartup(Entity* self) { auto* zoneControl = EntityManager::Instance()->GetZoneControlEntity(); @@ -20,11 +21,10 @@ void PropertyBankInteract::OnPlayerLoaded(Entity* self, Entity* player) { void PropertyBankInteract::OnUse(Entity* self, Entity* user) { AMFArrayValue args; - auto* value = new AMFStringValue(); - value->SetStringValue("bank"); - args.InsertValue("state", value); - GameMessages::SendUIMessageServerToSingleClient(user, user->GetSystemAddress(), "pushGameState", &args); + args.Insert("state", "bank"); + + GameMessages::SendUIMessageServerToSingleClient(user, user->GetSystemAddress(), "pushGameState", args); GameMessages::SendNotifyClientObject(self->GetObjectID(), u"OpenBank", 0, 0, LWOOBJID_EMPTY, "", user->GetSystemAddress()); @@ -34,9 +34,10 @@ void PropertyBankInteract::OnFireEventServerSide(Entity* self, Entity* sender, s int32_t param2, int32_t param3) { if (args == "ToggleBank") { AMFArrayValue amfArgs; - amfArgs.InsertValue("visible", new AMFFalseValue()); - GameMessages::SendUIMessageServerToSingleClient(sender, sender->GetSystemAddress(), "ToggleBank", &amfArgs); + amfArgs.Insert("visible", false); + + GameMessages::SendUIMessageServerToSingleClient(sender, sender->GetSystemAddress(), "ToggleBank", amfArgs); GameMessages::SendNotifyClientObject(self->GetObjectID(), u"CloseBank", 0, 0, LWOOBJID_EMPTY, "", sender->GetSystemAddress()); diff --git a/dScripts/02_server/Map/VE/VeBricksampleServer.cpp b/dScripts/02_server/Map/VE/VeBricksampleServer.cpp index 36306d07..0ead6a87 100644 --- a/dScripts/02_server/Map/VE/VeBricksampleServer.cpp +++ b/dScripts/02_server/Map/VE/VeBricksampleServer.cpp @@ -12,7 +12,7 @@ void VeBricksampleServer::OnUse(Entity* self, Entity* user) { auto* inventoryComponent = user->GetComponent(); if (loot && inventoryComponent != nullptr && inventoryComponent->GetLotCount(loot) == 0) { - inventoryComponent->AddItem(loot, 1, eLootSourceType::LOOT_SOURCE_ACTIVITY); + inventoryComponent->AddItem(loot, 1, eLootSourceType::ACTIVITY); for (auto* brickEntity : EntityManager::Instance()->GetEntitiesInGroup("Bricks")) { GameMessages::SendNotifyClientObject(brickEntity->GetObjectID(), u"Pickedup"); diff --git a/dScripts/02_server/Map/VE/VeEpsilonServer.h b/dScripts/02_server/Map/VE/VeEpsilonServer.h index 971cd93e..d5a53f9e 100644 --- a/dScripts/02_server/Map/VE/VeEpsilonServer.h +++ b/dScripts/02_server/Map/VE/VeEpsilonServer.h @@ -5,6 +5,6 @@ class VeEpsilonServer : public CppScripts::Script { void OnMissionDialogueOK(Entity* self, Entity* target, int missionID, eMissionState missionState) override; const uint32_t m_ConsoleMissionID = 1220; const uint32_t m_ConsoleRepeatMissionID = 1225; - const uint32_t m_ConsoleBaseFlag = 1010; + const int32_t m_ConsoleBaseFlag = 1010; const std::string m_ConsoleGroup = "Consoles"; }; diff --git a/dScripts/02_server/Map/VE/VeMissionConsole.cpp b/dScripts/02_server/Map/VE/VeMissionConsole.cpp index 534f8c06..35061bdf 100644 --- a/dScripts/02_server/Map/VE/VeMissionConsole.cpp +++ b/dScripts/02_server/Map/VE/VeMissionConsole.cpp @@ -3,18 +3,19 @@ #include "Character.h" #include "GameMessages.h" #include "Loot.h" +#include "eTerminateType.h" void VeMissionConsole::OnUse(Entity* self, Entity* user) { LootGenerator::Instance().DropActivityLoot(user, self, 12551); auto* inventoryComponent = user->GetComponent(); if (inventoryComponent != nullptr) { - inventoryComponent->AddItem(12547, 1, eLootSourceType::LOOT_SOURCE_ACTIVITY); // Add the panel required for pickup + inventoryComponent->AddItem(12547, 1, eLootSourceType::ACTIVITY); // Add the panel required for pickup } // The flag to set is 101 const auto flagNumber = self->GetVar(m_NumberVariable); - const auto flag = std::stoi("101" + GeneralUtils::UTF16ToWTF8(flagNumber)); + const int32_t flag = std::stoi("101" + GeneralUtils::UTF16ToWTF8(flagNumber)); auto* character = user->GetCharacter(); if (character != nullptr) { @@ -22,5 +23,5 @@ void VeMissionConsole::OnUse(Entity* self, Entity* user) { } GameMessages::SendNotifyClientObject(self->GetObjectID(), u""); - GameMessages::SendTerminateInteraction(user->GetObjectID(), FROM_INTERACTION, self->GetObjectID()); + GameMessages::SendTerminateInteraction(user->GetObjectID(), eTerminateType::FROM_INTERACTION, self->GetObjectID()); } diff --git a/dScripts/02_server/Map/njhub/CatapultBaseServer.cpp b/dScripts/02_server/Map/njhub/CatapultBaseServer.cpp index 55935c62..270e7f40 100644 --- a/dScripts/02_server/Map/njhub/CatapultBaseServer.cpp +++ b/dScripts/02_server/Map/njhub/CatapultBaseServer.cpp @@ -61,6 +61,6 @@ void CatapultBaseServer::OnTimerDone(Entity* self, std::string timerName) { // kill the bouncer GameMessages::SendNotifyClientObject(bouncer->GetObjectID(), u"TimeToDie"); - bouncer->Smash(self->GetObjectID(), VIOLENT); + bouncer->Smash(self->GetObjectID(), eKillType::VIOLENT); } } diff --git a/dScripts/02_server/Map/njhub/CavePrisonCage.cpp b/dScripts/02_server/Map/njhub/CavePrisonCage.cpp index 14cf6719..d04fc03d 100644 --- a/dScripts/02_server/Map/njhub/CavePrisonCage.cpp +++ b/dScripts/02_server/Map/njhub/CavePrisonCage.cpp @@ -46,7 +46,7 @@ void CavePrisonCage::Setup(Entity* self, Spawner* spawner) { } void CavePrisonCage::OnRebuildNotifyState(Entity* self, eRebuildState state) { - if (state != eRebuildState::REBUILD_RESETTING) { + if (state != eRebuildState::RESETTING) { return; } diff --git a/dScripts/02_server/Map/njhub/ImaginationShrineServer.cpp b/dScripts/02_server/Map/njhub/ImaginationShrineServer.cpp index 267d0480..1fbfad98 100644 --- a/dScripts/02_server/Map/njhub/ImaginationShrineServer.cpp +++ b/dScripts/02_server/Map/njhub/ImaginationShrineServer.cpp @@ -9,7 +9,7 @@ void ImaginationShrineServer::OnUse(Entity* self, Entity* user) { return; } - if (rebuildComponent->GetState() == REBUILD_COMPLETED) { + if (rebuildComponent->GetState() == eRebuildState::COMPLETED) { // Use the shrine BaseUse(self, user); } diff --git a/dScripts/02_server/Map/njhub/NjColeNPC.cpp b/dScripts/02_server/Map/njhub/NjColeNPC.cpp index 672fdd95..b989f3ee 100644 --- a/dScripts/02_server/Map/njhub/NjColeNPC.cpp +++ b/dScripts/02_server/Map/njhub/NjColeNPC.cpp @@ -44,6 +44,6 @@ void NjColeNPC::OnMissionDialogueOK(Entity* self, Entity* target, int missionID, return; } - inventoryComponent->AddItem(16644, 1, eLootSourceType::LOOT_SOURCE_NONE); + inventoryComponent->AddItem(16644, 1, eLootSourceType::NONE); } } diff --git a/dScripts/02_server/Map/njhub/NjDragonEmblemChestServer.cpp b/dScripts/02_server/Map/njhub/NjDragonEmblemChestServer.cpp index be9fcbd9..931cfe56 100644 --- a/dScripts/02_server/Map/njhub/NjDragonEmblemChestServer.cpp +++ b/dScripts/02_server/Map/njhub/NjDragonEmblemChestServer.cpp @@ -4,11 +4,12 @@ #include "Loot.h" #include "Entity.h" #include "DestroyableComponent.h" +#include "ePlayerFlag.h" void NjDragonEmblemChestServer::OnUse(Entity* self, Entity* user) { auto* character = user->GetCharacter(); if (character != nullptr) { - character->SetPlayerFlag(NJ_WU_SHOW_DAILY_CHEST, false); + character->SetPlayerFlag(ePlayerFlag::NJ_WU_SHOW_DAILY_CHEST, false); } auto* destroyable = self->GetComponent(); diff --git a/dScripts/02_server/Map/njhub/NjGarmadonCelebration.cpp b/dScripts/02_server/Map/njhub/NjGarmadonCelebration.cpp index c223c55c..d3e54be1 100644 --- a/dScripts/02_server/Map/njhub/NjGarmadonCelebration.cpp +++ b/dScripts/02_server/Map/njhub/NjGarmadonCelebration.cpp @@ -1,6 +1,7 @@ #include "NjGarmadonCelebration.h" #include "Character.h" #include "GameMessages.h" +#include "ePlayerFlag.h" void NjGarmadonCelebration::OnCollisionPhantom(Entity* self, Entity* target) { auto* character = target->GetCharacter(); @@ -9,8 +10,8 @@ void NjGarmadonCelebration::OnCollisionPhantom(Entity* self, Entity* target) { return; } - if (!character->GetPlayerFlag(ePlayerFlags::NJ_GARMADON_CINEMATIC_SEEN)) { - character->SetPlayerFlag(ePlayerFlags::NJ_GARMADON_CINEMATIC_SEEN, true); + if (!character->GetPlayerFlag(ePlayerFlag::NJ_GARMADON_CINEMATIC_SEEN)) { + character->SetPlayerFlag(ePlayerFlag::NJ_GARMADON_CINEMATIC_SEEN, true); GameMessages::SendStartCelebrationEffect(target, target->GetSystemAddress(), GarmadonCelebrationID); } diff --git a/dScripts/02_server/Map/njhub/NjNPCMissionSpinjitzuServer.h b/dScripts/02_server/Map/njhub/NjNPCMissionSpinjitzuServer.h index 3c705925..116ecc93 100644 --- a/dScripts/02_server/Map/njhub/NjNPCMissionSpinjitzuServer.h +++ b/dScripts/02_server/Map/njhub/NjNPCMissionSpinjitzuServer.h @@ -1,12 +1,13 @@ #pragma once #include "CppScripts.h" #include +#include "ePlayerFlag.h" -static std::map ElementFlags = { - {u"earth", ePlayerFlags::NJ_EARTH_SPINJITZU}, - {u"lightning", ePlayerFlags::NJ_LIGHTNING_SPINJITZU}, - {u"ice", ePlayerFlags::NJ_ICE_SPINJITZU}, - {u"fire", ePlayerFlags::NJ_FIRE_SPINJITZU} +static std::map ElementFlags = { + {u"earth", ePlayerFlag::NJ_EARTH_SPINJITZU}, + {u"lightning", ePlayerFlag::NJ_LIGHTNING_SPINJITZU}, + {u"ice", ePlayerFlag::NJ_ICE_SPINJITZU}, + {u"fire", ePlayerFlag::NJ_FIRE_SPINJITZU} }; static std::map ElementMissions = { diff --git a/dScripts/02_server/Map/njhub/NjScrollChestServer.cpp b/dScripts/02_server/Map/njhub/NjScrollChestServer.cpp index 4e1350b4..7156b368 100644 --- a/dScripts/02_server/Map/njhub/NjScrollChestServer.cpp +++ b/dScripts/02_server/Map/njhub/NjScrollChestServer.cpp @@ -12,6 +12,6 @@ void NjScrollChestServer::OnUse(Entity* self, Entity* user) { playerInventory->RemoveItem(keyLOT, 1); // Reward the player with the item set - playerInventory->AddItem(rewardItemLOT, 1, eLootSourceType::LOOT_SOURCE_NONE); + playerInventory->AddItem(rewardItemLOT, 1, eLootSourceType::NONE); } } diff --git a/dScripts/02_server/Map/njhub/NjWuNPC.cpp b/dScripts/02_server/Map/njhub/NjWuNPC.cpp index 9efc623b..f4969074 100644 --- a/dScripts/02_server/Map/njhub/NjWuNPC.cpp +++ b/dScripts/02_server/Map/njhub/NjWuNPC.cpp @@ -4,6 +4,7 @@ #include "EntityManager.h" #include "GameMessages.h" #include "eMissionState.h" +#include "ePlayerFlag.h" void NjWuNPC::OnMissionDialogueOK(Entity* self, Entity* target, int missionID, eMissionState missionState) { @@ -24,7 +25,7 @@ void NjWuNPC::OnMissionDialogueOK(Entity* self, Entity* target, int missionID, e missionComponent->AcceptMission(subMissionID); } - character->SetPlayerFlag(ePlayerFlags::NJ_WU_SHOW_DAILY_CHEST, false); + character->SetPlayerFlag(ePlayerFlag::NJ_WU_SHOW_DAILY_CHEST, false); // Hide the chest for (auto* chest : EntityManager::Instance()->GetEntitiesInGroup(m_DragonChestGroup)) { @@ -37,7 +38,7 @@ void NjWuNPC::OnMissionDialogueOK(Entity* self, Entity* target, int missionID, e case eMissionState::READY_TO_COMPLETE: case eMissionState::COMPLETE_READY_TO_COMPLETE: { - character->SetPlayerFlag(NJ_WU_SHOW_DAILY_CHEST, true); + character->SetPlayerFlag(ePlayerFlag::NJ_WU_SHOW_DAILY_CHEST, true); // Show the chest for (auto* chest : EntityManager::Instance()->GetEntitiesInGroup(m_DragonChestGroup)) { diff --git a/dScripts/02_server/Map/njhub/boss_instance/NjMonastryBossInstance.cpp b/dScripts/02_server/Map/njhub/boss_instance/NjMonastryBossInstance.cpp index d5880029..9f129ce3 100644 --- a/dScripts/02_server/Map/njhub/boss_instance/NjMonastryBossInstance.cpp +++ b/dScripts/02_server/Map/njhub/boss_instance/NjMonastryBossInstance.cpp @@ -226,21 +226,21 @@ void NjMonastryBossInstance::HandleCounterWeightSpawned(Entity* self, Entity* co rebuildComponent->AddRebuildStateCallback([this, self, counterWeight](eRebuildState state) { switch (state) { - case REBUILD_BUILDING: + case eRebuildState::BUILDING: GameMessages::SendNotifyClientObject(self->GetObjectID(), PlayCinematicNotification, 0, 0, counterWeight->GetObjectID(), BaseCounterweightQB + std::to_string(self->GetVar(WaveNumberVariable)), UNASSIGNED_SYSTEM_ADDRESS); return; - case REBUILD_INCOMPLETE: + case eRebuildState::INCOMPLETE: GameMessages::SendNotifyClientObject(self->GetObjectID(), EndCinematicNotification, 0, 0, LWOOBJID_EMPTY, "", UNASSIGNED_SYSTEM_ADDRESS); return; - case REBUILD_RESETTING: + case eRebuildState::RESETTING: ActivityTimerStart(self, SpawnCounterWeightTimer, 0.0f, 0.0f); return; - case REBUILD_COMPLETED: { + case eRebuildState::COMPLETED: { // TODO: Move the platform? // The counterweight is actually a moving platform and we should listen to the last waypoint event here diff --git a/dScripts/02_server/Pets/DamagingPets.cpp b/dScripts/02_server/Pets/DamagingPets.cpp index f7eada00..6fd8c560 100644 --- a/dScripts/02_server/Pets/DamagingPets.cpp +++ b/dScripts/02_server/Pets/DamagingPets.cpp @@ -3,6 +3,7 @@ #include "DestroyableComponent.h" #include "BaseCombatAIComponent.h" #include "RenderComponent.h" +#include "ePetTamingNotifyType.h" void DamagingPets::OnStartup(Entity* self) { @@ -33,15 +34,15 @@ void DamagingPets::OnPlayerLoaded(Entity* self, Entity* player) { }); } -void DamagingPets::OnNotifyPetTamingMinigame(Entity* self, Entity* tamer, eNotifyType type) { +void DamagingPets::OnNotifyPetTamingMinigame(Entity* self, Entity* tamer, ePetTamingNotifyType type) { switch (type) { - case NOTIFY_TYPE_SUCCESS: - case NOTIFY_TYPE_BEGIN: + case ePetTamingNotifyType::SUCCESS: + case ePetTamingNotifyType::BEGIN: self->CancelAllTimers(); ClearEffects(self); break; - case NOTIFY_TYPE_FAILED: - case NOTIFY_TYPE_QUIT: + case ePetTamingNotifyType::FAILED: + case ePetTamingNotifyType::QUIT: { self->SetNetworkVar(u"bIAmTamable", false); self->AddTimer("GoEvil", 1.0f); diff --git a/dScripts/02_server/Pets/DamagingPets.h b/dScripts/02_server/Pets/DamagingPets.h index 2ce0ddc1..303bff52 100644 --- a/dScripts/02_server/Pets/DamagingPets.h +++ b/dScripts/02_server/Pets/DamagingPets.h @@ -13,7 +13,7 @@ class DamagingPets : public CppScripts::Script { public: void OnStartup(Entity* self) override; void OnTimerDone(Entity* self, std::string message) override; - void OnNotifyPetTamingMinigame(Entity* self, Entity* tamer, eNotifyType type) override; + void OnNotifyPetTamingMinigame(Entity* self, Entity* tamer, ePetTamingNotifyType type) override; void OnSkillEventFired(Entity* self, Entity* target, const std::string& message) override; void OnPlayerLoaded(Entity* self, Entity* player) override; private: diff --git a/dScripts/02_server/Pets/PetFromDigServer.cpp b/dScripts/02_server/Pets/PetFromDigServer.cpp index 5aca7486..525f3e94 100644 --- a/dScripts/02_server/Pets/PetFromDigServer.cpp +++ b/dScripts/02_server/Pets/PetFromDigServer.cpp @@ -1,5 +1,6 @@ #include "PetFromDigServer.h" #include "PetComponent.h" +#include "ePetTamingNotifyType.h" void PetFromDigServer::OnStartup(Entity* self) { auto* petComponent = self->GetComponent(); @@ -24,16 +25,16 @@ void PetFromDigServer::OnTimerDone(Entity* self, std::string timerName) { if (petComponent == nullptr || petComponent->GetOwner() != nullptr) return; - self->Smash(self->GetObjectID(), SILENT); + self->Smash(self->GetObjectID(), eKillType::SILENT); } } -void PetFromDigServer::OnNotifyPetTamingMinigame(Entity* self, Entity* tamer, eNotifyType type) { - if (type == NOTIFY_TYPE_BEGIN) { +void PetFromDigServer::OnNotifyPetTamingMinigame(Entity* self, Entity* tamer, ePetTamingNotifyType type) { + if (type == ePetTamingNotifyType::BEGIN) { self->CancelTimer("killself"); - } else if (type == NOTIFY_TYPE_QUIT || type == NOTIFY_TYPE_FAILED) { - self->Smash(self->GetObjectID(), SILENT); - } else if (type == NOTIFY_TYPE_SUCCESS) { + } else if (type == ePetTamingNotifyType::QUIT || type == ePetTamingNotifyType::FAILED) { + self->Smash(self->GetObjectID(), eKillType::SILENT); + } else if (type == ePetTamingNotifyType::SUCCESS) { auto* petComponent = self->GetComponent(); if (petComponent == nullptr) return; diff --git a/dScripts/02_server/Pets/PetFromDigServer.h b/dScripts/02_server/Pets/PetFromDigServer.h index 3faf248d..aaf31728 100644 --- a/dScripts/02_server/Pets/PetFromDigServer.h +++ b/dScripts/02_server/Pets/PetFromDigServer.h @@ -6,5 +6,5 @@ class PetFromDigServer : public CppScripts::Script public: void OnStartup(Entity* self) override; void OnTimerDone(Entity* self, std::string timerName) override; - void OnNotifyPetTamingMinigame(Entity* self, Entity* tamer, eNotifyType type) override; + void OnNotifyPetTamingMinigame(Entity* self, Entity* tamer, ePetTamingNotifyType type) override; }; diff --git a/dScripts/02_server/Pets/PetFromObjectServer.cpp b/dScripts/02_server/Pets/PetFromObjectServer.cpp index 899b394a..0a78d7ec 100644 --- a/dScripts/02_server/Pets/PetFromObjectServer.cpp +++ b/dScripts/02_server/Pets/PetFromObjectServer.cpp @@ -1,5 +1,6 @@ #include "PetFromObjectServer.h" #include "PetComponent.h" +#include "ePetTamingNotifyType.h" void PetFromObjectServer::OnStartup(Entity* self) { self->SetNetworkVar(u"pettamer", std::to_string(self->GetVar(u"tamer"))); @@ -11,20 +12,20 @@ void PetFromObjectServer::OnTimerDone(Entity* self, std::string timerName) { const auto* petComponent = self->GetComponent(); if (petComponent == nullptr || petComponent->GetOwner() != nullptr) return; - self->Smash(self->GetObjectID(), SILENT); + self->Smash(self->GetObjectID(), eKillType::SILENT); } } -void PetFromObjectServer::OnNotifyPetTamingMinigame(Entity* self, Entity* tamer, eNotifyType type) { +void PetFromObjectServer::OnNotifyPetTamingMinigame(Entity* self, Entity* tamer, ePetTamingNotifyType type) { switch (type) { - case NOTIFY_TYPE_BEGIN: + case ePetTamingNotifyType::BEGIN: self->CancelAllTimers(); break; - case NOTIFY_TYPE_QUIT: - case NOTIFY_TYPE_FAILED: - self->Smash(self->GetObjectID(), SILENT); + case ePetTamingNotifyType::QUIT: + case ePetTamingNotifyType::FAILED: + self->Smash(self->GetObjectID(), eKillType::SILENT); break; - case NOTIFY_TYPE_SUCCESS: + case ePetTamingNotifyType::SUCCESS: // TODO: Remove from groups? GameMessages::SendNotifyClientObject(self->GetObjectID(), u"UpdateSuccessPicking", 0, 0, tamer->GetObjectID(), "", UNASSIGNED_SYSTEM_ADDRESS); diff --git a/dScripts/02_server/Pets/PetFromObjectServer.h b/dScripts/02_server/Pets/PetFromObjectServer.h index 1a7c244b..67cd5eb0 100644 --- a/dScripts/02_server/Pets/PetFromObjectServer.h +++ b/dScripts/02_server/Pets/PetFromObjectServer.h @@ -5,5 +5,5 @@ class PetFromObjectServer : public CppScripts::Script { public: void OnStartup(Entity* self) override; void OnTimerDone(Entity* self, std::string timerName) override; - void OnNotifyPetTamingMinigame(Entity* self, Entity* tamer, eNotifyType type) override; + void OnNotifyPetTamingMinigame(Entity* self, Entity* tamer, ePetTamingNotifyType type) override; }; diff --git a/dScripts/BaseConsoleTeleportServer.cpp b/dScripts/BaseConsoleTeleportServer.cpp index 41dde4c4..e04500b5 100644 --- a/dScripts/BaseConsoleTeleportServer.cpp +++ b/dScripts/BaseConsoleTeleportServer.cpp @@ -3,6 +3,8 @@ #include "Player.h" #include "RenderComponent.h" #include "EntityManager.h" +#include "eTerminateType.h" +#include "eStateChangeType.h" void BaseConsoleTeleportServer::BaseOnUse(Entity* self, Entity* user) { auto* player = user; @@ -52,7 +54,7 @@ void BaseConsoleTeleportServer::BaseOnMessageBoxResponse(Entity* self, Entity* s GameMessages::SendDisplayZoneSummary(playerID, player->GetSystemAddress(), false, false, self->GetObjectID()); }); } else if (button == -1 || button == 0) { - GameMessages::SendTerminateInteraction(player->GetObjectID(), FROM_INTERACTION, player->GetObjectID()); + GameMessages::SendTerminateInteraction(player->GetObjectID(), eTerminateType::FROM_INTERACTION, player->GetObjectID()); } } @@ -88,7 +90,7 @@ void BaseConsoleTeleportServer::TransferPlayer(Entity* self, Entity* player, int true, true, true, true, true, true, true ); - GameMessages::SendTerminateInteraction(player->GetObjectID(), FROM_INTERACTION, player->GetObjectID()); + GameMessages::SendTerminateInteraction(player->GetObjectID(), eTerminateType::FROM_INTERACTION, player->GetObjectID()); const auto& teleportZone = self->GetVar(u"transferZoneID"); diff --git a/dScripts/BasePropertyServer.cpp b/dScripts/BasePropertyServer.cpp index a9f35e25..72cce09f 100644 --- a/dScripts/BasePropertyServer.cpp +++ b/dScripts/BasePropertyServer.cpp @@ -38,8 +38,8 @@ void BasePropertyServer::SetGameVariables(Entity* self) { self->SetVar>(AmbientFXSpawner, {}); self->SetVar>(BehaviorObjsSpawner, {}); - self->SetVar(defeatedProperyFlag, 0); - self->SetVar(placedModelFlag, 0); + self->SetVar(defeatedProperyFlag, 0); + self->SetVar(placedModelFlag, 0); self->SetVar(guardMissionFlag, 0); self->SetVar(brickLinkMissionIDFlag, 0); self->SetVar(passwordFlag, "s3kratK1ttN"); @@ -127,7 +127,7 @@ void BasePropertyServer::BasePlayerLoaded(Entity* self, Entity* player) { if (player->GetObjectID() != propertyOwner) return; } else { - const auto defeatedFlag = player->GetCharacter()->GetPlayerFlag(self->GetVar(defeatedProperyFlag)); + const auto defeatedFlag = player->GetCharacter()->GetPlayerFlag(self->GetVar(defeatedProperyFlag)); self->SetNetworkVar(UnclaimedVariable, true); self->SetVar(PlayerIDVariable, player->GetObjectID()); @@ -274,7 +274,7 @@ void BasePropertyServer::RequestDie(Entity* self, Entity* other) { if (destroyable == nullptr) return; - destroyable->Smash(other->GetObjectID(), SILENT); + destroyable->Smash(other->GetObjectID(), eKillType::SILENT); } void BasePropertyServer::ActivateSpawner(const std::string& spawnerName) { @@ -464,7 +464,7 @@ void BasePropertyServer::HandleOrbsTimer(Entity* self) { if (player != nullptr) { auto* character = player->GetCharacter(); if (character != nullptr) { - character->SetPlayerFlag(self->GetVar(defeatedProperyFlag), true); + character->SetPlayerFlag(self->GetVar(defeatedProperyFlag), true); } } diff --git a/dScripts/ChooseYourDestinationNsToNt.cpp b/dScripts/ChooseYourDestinationNsToNt.cpp index e50d70c5..f9ca0a79 100644 --- a/dScripts/ChooseYourDestinationNsToNt.cpp +++ b/dScripts/ChooseYourDestinationNsToNt.cpp @@ -1,6 +1,7 @@ #include "ChooseYourDestinationNsToNt.h" #include "Character.h" #include "GameMessages.h" +#include "eTerminateType.h" bool ChooseYourDestinationNsToNt::CheckChoice(Entity* self, Entity* player) { const auto choiceZoneID = self->GetVar(u"choiceZone"); @@ -59,6 +60,6 @@ void ChooseYourDestinationNsToNt::BaseChoiceBoxRespond(Entity* self, Entity* sen GameMessages::SendDisplayMessageBox(sender->GetObjectID(), true, self->GetObjectID(), u"TransferBox", 0, strText, u"", sender->GetSystemAddress()); } else { - GameMessages::SendTerminateInteraction(sender->GetObjectID(), FROM_INTERACTION, self->GetObjectID()); + GameMessages::SendTerminateInteraction(sender->GetObjectID(), eTerminateType::FROM_INTERACTION, self->GetObjectID()); } } diff --git a/dScripts/CppScripts.cpp b/dScripts/CppScripts.cpp index 24b30dee..5459fd37 100644 --- a/dScripts/CppScripts.cpp +++ b/dScripts/CppScripts.cpp @@ -160,7 +160,6 @@ #include "AgSalutingNpcs.h" #include "BossSpiderQueenEnemyServer.h" #include "RockHydrantSmashable.h" -#include "SpecialImaginePowerupSpawner.h" // Misc Scripts #include "ExplodingAsset.h" @@ -295,6 +294,24 @@ // WBL scripts #include "WblGenericZone.h" +// Alpha Scripts +#include "TriggerGas.h" +#include "ActNinjaSensei.h" + +// pickups +#include "SpecialCoinSpawner.h" +#include "SpecialPowerupSpawner.h" +#include "SpecialSpeedBuffSpawner.h" + +// Wild Scripts +#include "WildAndScared.h" +#include "WildGfGlowbug.h" +#include "WildAmbientCrab.h" +#include "WildPants.h" +#include "WildNinjaStudent.h" +#include "WildNinjaSensei.h" +#include "WildNinjaBricks.h" + //Big bad global bc this is a namespace and not a class: InvalidScript* invalidToReturn = new InvalidScript(); std::map m_Scripts; @@ -371,8 +388,6 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr script = new RemoveRentalGear(); else if (scriptName == "scripts\\02_server\\Map\\AG\\L_NPC_NJ_ASSISTANT_SERVER.lua") script = new NpcNjAssistantServer(); - else if (scriptName == "scripts\\ai\\SPEC\\L_SPECIAL_IMAGINE-POWERUP-SPAWNER.lua") - script = new SpecialImaginePowerupSpawner(); else if (scriptName == "scripts\\ai\\AG\\L_AG_SALUTING_NPCS.lua") script = new AgSalutingNpcs(); else if (scriptName == "scripts\\ai\\AG\\L_AG_JET_EFFECT_SERVER.lua") @@ -860,11 +875,65 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr else if (scriptName == "scripts\\zone\\LUPs\\WBL_generic_zone.lua") script = new WblGenericZone(); + // Alpha + if (scriptName == "scripts\\ai\\FV\\L_TRIGGER_GAS.lua") + script = new TriggerGas(); + else if (scriptName == "scripts\\ai\\FV\\L_ACT_NINJA_SENSEI.lua") + script = new ActNinjaSensei(); + + // pickups + if (scriptName == "scripts\\ai\\SPEC\\L_SPECIAL_1_BRONZE-COIN-SPAWNER.lua") + script = new SpecialCoinSpawner(1); + else if (scriptName == "scripts\\ai\\SPEC\\L_SPECIAL_1_GOLD-COIN-SPAWNER.lua") + script = new SpecialCoinSpawner(10000); + else if (scriptName == "scripts\\ai\\SPEC\\L_SPECIAL_1_SILVER-COIN-SPAWNER.lua") + script = new SpecialCoinSpawner(100); + else if (scriptName == "scripts\\ai\\SPEC\\L_SPECIAL_10_BRONZE-COIN-SPAWNER.lua") + script = new SpecialCoinSpawner(10); + else if (scriptName == "scripts\\ai\\SPEC\\L_SPECIAL_10_GOLD-COIN-SPAWNER.lua") + script = new SpecialCoinSpawner(100000); + else if (scriptName == "scripts\\ai\\SPEC\\L_SPECIAL_10_SILVER-COIN-SPAWNER.lua") + script = new SpecialCoinSpawner(1000); + else if (scriptName == "scripts\\ai\\SPEC\\L_SPECIAL_25_BRONZE-COIN-SPAWNER.lua") + script = new SpecialCoinSpawner(25); + else if (scriptName == "scripts\\ai\\SPEC\\L_SPECIAL_25_GOLD-COIN-SPAWNER.lua") + script = new SpecialCoinSpawner(250000); + else if (scriptName == "scripts\\ai\\SPEC\\L_SPECIAL_25_SILVER-COIN-SPAWNER.lua") + script = new SpecialCoinSpawner(2500); + else if (scriptName == "scripts\\ai\\SPEC\\L_SPECIAL_IMAGINE-POWERUP-SPAWNER.lua") + script = new SpecialPowerupSpawner(13); + else if (scriptName == "scripts\\ai\\SPEC\\L_SPECIAL_IMAGINE-POWERUP-SPAWNER-2PT.lua") + script = new SpecialPowerupSpawner(129); + else if (scriptName == "scripts\\ai\\SPEC\\L_SPECIAL_LIFE-POWERUP-SPAWNER.lua") + script = new SpecialPowerupSpawner(5); + else if (scriptName == "scripts\\ai\\SPEC\\L_SPECIAL_ARMOR-POWERUP-SPAWNER.lua") + script = new SpecialPowerupSpawner(747); + else if (scriptName == "scripts\\ai\\SPEC\\L_SPECIAL_SPEED_BUFF_SPAWNER.lua") + script = new SpecialSpeedBuffSpawner(); + + // Wild + if (scriptName == "scripts\\ai\\WILD\\L_WILD_GF_RAT.lua" || scriptName == "scripts\\ai\\WILD\\L_WILD_GF_SNAIL.lua") + script = new WildAndScared(); + else if (scriptName == "scripts\\ai\\WILD\\L_WILD_GF_GLOWBUG.lua") + script = new WildGfGlowbug(); + else if (scriptName == "scripts\\ai\\WILD\\L_WILD_AMBIENT_CRAB.lua") + script = new WildAmbientCrab(); + else if (scriptName == "scripts\\ai\\WILD\\L_WILD_PANTS.lua") + script = new WildPants(); + else if (scriptName == "scripts\\ai\\WILD\\L_WILD_NINJA_BRICKS.lua") + script = new WildNinjaBricks(); + else if (scriptName == "scripts\\ai\\WILD\\L_WILD_NINJA_STUDENT.lua") + script = new WildNinjaStudent(); + else if (scriptName == "scripts\\ai\\WILD\\L_WILD_NINJA_SENSEI.lua") + script = new WildNinjaSensei(); + // handle invalid script reporting if the path is greater than zero and it's not an ignored script // information not really needed for sys admins but is for developers else if (script == invalidToReturn) { if ((scriptName.length() > 0) && !((scriptName == "scripts\\02_server\\Enemy\\General\\L_SUSPEND_LUA_AI.lua") || (scriptName == "scripts\\02_server\\Enemy\\General\\L_BASE_ENEMY_SPIDERLING.lua") || + (scriptName =="scripts\\ai\\FV\\L_ACT_NINJA_STUDENT.lua") || + (scriptName == "scripts\\ai\\WILD\\L_WILD_GF_FROG.lua") || (scriptName == "scripts\\empty.lua") )) Game::logger->LogDebug("CppScripts", "LOT %i attempted to load CppScript for '%s', but returned InvalidScript.", parent->GetLOT(), scriptName.c_str()); } diff --git a/dScripts/CppScripts.h b/dScripts/CppScripts.h index 21ff8427..1b9d0591 100644 --- a/dScripts/CppScripts.h +++ b/dScripts/CppScripts.h @@ -8,6 +8,8 @@ class User; class Entity; class NiPoint3; enum class eMissionState : int32_t; +enum class ePetTamingNotifyType : uint32_t; +enum class eRebuildState : uint32_t; namespace CppScripts { /** @@ -44,6 +46,13 @@ namespace CppScripts { */ virtual void OnCollisionPhantom(Entity* self, Entity* target) {}; + /** + * Invoked upon an entity leaving the phantom collider on self. + * + * Equivalent to 'function onOffCollisionPhantom(self, msg)' + */ + virtual void OnOffCollisionPhantom(Entity* self, Entity* target) {}; + /** * Invoked when a player accepted a mission. * @@ -262,7 +271,7 @@ namespace CppScripts { * * Equivalent to 'function onNotifyPetTamingMinigame(self, msg)' */ - virtual void OnNotifyPetTamingMinigame(Entity* self, Entity* tamer, eNotifyType type) {}; + virtual void OnNotifyPetTamingMinigame(Entity* self, Entity* tamer, ePetTamingNotifyType type) {}; /** * Invoked when a player responded to a message box. @@ -340,6 +349,15 @@ namespace CppScripts { * @param itemObjId The items Object ID */ virtual void OnFactionTriggerItemUnequipped(Entity* itemOwner, LWOOBJID itemObjId) {}; + + /** + * Handles exiting a scripted activity + * + * @param sender + * @param player the player to remove + * @param canceled if it was done via the cancel button + */ + virtual void OnRequestActivityExit(Entity* sender, LWOOBJID player, bool canceled){}; }; Script* GetScript(Entity* parent, const std::string& scriptName); diff --git a/dScripts/EquipmentScripts/PersonalFortress.cpp b/dScripts/EquipmentScripts/PersonalFortress.cpp index f5062f9b..f1fe73ee 100644 --- a/dScripts/EquipmentScripts/PersonalFortress.cpp +++ b/dScripts/EquipmentScripts/PersonalFortress.cpp @@ -4,6 +4,7 @@ #include "DestroyableComponent.h" #include "ControllablePhysicsComponent.h" #include "EntityManager.h" +#include "eStateChangeType.h" void PersonalFortress::OnStartup(Entity* self) { auto* owner = self->GetOwner(); diff --git a/dScripts/EquipmentScripts/StunImmunity.cpp b/dScripts/EquipmentScripts/StunImmunity.cpp index f35fe261..0ec956f0 100644 --- a/dScripts/EquipmentScripts/StunImmunity.cpp +++ b/dScripts/EquipmentScripts/StunImmunity.cpp @@ -1,6 +1,7 @@ #include "StunImmunity.h" #include "DestroyableComponent.h" #include "ControllablePhysicsComponent.h" +#include "eStateChangeType.h" void StunImmunity::OnStartup(Entity* self) { auto* destroyableComponent = self->GetComponent(); diff --git a/dScripts/NPCAddRemoveItem.cpp b/dScripts/NPCAddRemoveItem.cpp index f1ef8c0d..13677072 100644 --- a/dScripts/NPCAddRemoveItem.cpp +++ b/dScripts/NPCAddRemoveItem.cpp @@ -12,7 +12,7 @@ void NPCAddRemoveItem::OnMissionDialogueOK(Entity* self, Entity* target, int mis for (const auto& itemSetting : missionSetting.second) { for (const auto& lot : itemSetting.items) { if (itemSetting.add && (missionState == eMissionState::AVAILABLE || missionState == eMissionState::COMPLETE_AVAILABLE)) { - inventory->AddItem(lot, 1, eLootSourceType::LOOT_SOURCE_NONE); + inventory->AddItem(lot, 1, eLootSourceType::NONE); } else if (itemSetting.remove && (missionState == eMissionState::READY_TO_COMPLETE || missionState == eMissionState::COMPLETE_READY_TO_COMPLETE)) { inventory->RemoveItem(lot, 1); } diff --git a/dScripts/NtFactionSpyServer.cpp b/dScripts/NtFactionSpyServer.cpp index dc62855a..a1161880 100644 --- a/dScripts/NtFactionSpyServer.cpp +++ b/dScripts/NtFactionSpyServer.cpp @@ -6,6 +6,8 @@ #include "MissionComponent.h" #include "eMissionState.h" #include "eReplicaComponentType.h" +#include "eCinematicEvent.h" +#include "ePlayerFlag.h" void NtFactionSpyServer::OnStartup(Entity* self) { SetVariables(self); @@ -77,14 +79,14 @@ void NtFactionSpyServer::OnCinematicUpdate(Entity* self, Entity* sender, eCinema // Make sure we're listening to the root we're interested in if (pathRoot == cinematicRoot) { - if (event == STARTED && pathIndex >= 0 && pathIndex < dialogueTable.size()) { + if (event == eCinematicEvent::STARTED && pathIndex >= 0 && pathIndex < dialogueTable.size()) { // If the cinematic started, show part of the conversation GameMessages::SendNotifyClientObject(self->GetObjectID(), m_SpyDialogueNotification, 0, 0, ParamObjectForConversationID(self, dialogueTable.at(pathIndex).conversationID), dialogueTable.at(pathIndex).token, sender->GetSystemAddress()); - } else if (event == ENDED && pathIndex >= dialogueTable.size() - 1) { + } else if (event == eCinematicEvent::ENDED && pathIndex >= dialogueTable.size() - 1) { auto spyData = self->GetVar(m_SpyDataVariable); auto* character = sender->GetCharacter(); if (character != nullptr) { diff --git a/dScripts/NtFactionSpyServer.h b/dScripts/NtFactionSpyServer.h index 67955dd4..4406859c 100644 --- a/dScripts/NtFactionSpyServer.h +++ b/dScripts/NtFactionSpyServer.h @@ -7,7 +7,7 @@ struct SpyDialogue { }; struct SpyData { - uint32_t flagID; + int32_t flagID; LOT itemID; uint32_t missionID; }; diff --git a/dScripts/SpawnPetBaseServer.cpp b/dScripts/SpawnPetBaseServer.cpp index d3c87288..75b46382 100644 --- a/dScripts/SpawnPetBaseServer.cpp +++ b/dScripts/SpawnPetBaseServer.cpp @@ -3,6 +3,7 @@ #include "EntityManager.h" #include "PetComponent.h" #include "EntityInfo.h" +#include "eTerminateType.h" void SpawnPetBaseServer::OnStartup(Entity* self) { SetVariables(self); @@ -43,7 +44,7 @@ void SpawnPetBaseServer::OnUse(Entity* self, Entity* user) { GameMessages::SendPlayCinematic(user->GetObjectID(), spawnCinematic, UNASSIGNED_SYSTEM_ADDRESS); } - GameMessages::SendTerminateInteraction(user->GetObjectID(), FROM_INTERACTION, self->GetObjectID()); + GameMessages::SendTerminateInteraction(user->GetObjectID(), eTerminateType::FROM_INTERACTION, self->GetObjectID()); } bool SpawnPetBaseServer::CheckNumberOfPets(Entity* self, Entity* user) { diff --git a/dScripts/ai/ACT/ActMine.cpp b/dScripts/ai/ACT/ActMine.cpp index 637bd805..9651e13d 100644 --- a/dScripts/ai/ACT/ActMine.cpp +++ b/dScripts/ai/ACT/ActMine.cpp @@ -9,7 +9,7 @@ void ActMine::OnStartup(Entity* self) { } void ActMine::OnRebuildNotifyState(Entity* self, eRebuildState state) { - if (state == eRebuildState::REBUILD_COMPLETED) { + if (state == eRebuildState::COMPLETED) { auto* rebuild = self->GetComponent(); if (rebuild) { auto* builder = rebuild->GetBuilder(); diff --git a/dScripts/ai/ACT/ActVehicleDeathTrigger.cpp b/dScripts/ai/ACT/ActVehicleDeathTrigger.cpp index 77a3b65a..76c0289e 100644 --- a/dScripts/ai/ACT/ActVehicleDeathTrigger.cpp +++ b/dScripts/ai/ACT/ActVehicleDeathTrigger.cpp @@ -40,7 +40,7 @@ void ActVehicleDeathTrigger::OnCollisionPhantom(Entity* self, Entity* target) { } - GameMessages::SendDie(vehicle, self->GetObjectID(), LWOOBJID_EMPTY, true, VIOLENT, u"", 0, 0, 0, true, false, 0); + GameMessages::SendDie(vehicle, self->GetObjectID(), LWOOBJID_EMPTY, true, eKillType::VIOLENT, u"", 0, 0, 0, true, false, 0); auto* zoneController = dZoneManager::Instance()->GetZoneControlObject(); diff --git a/dScripts/ai/ACT/FootRace/BaseFootRaceManager.cpp b/dScripts/ai/ACT/FootRace/BaseFootRaceManager.cpp index 699ee096..4d1ae5f5 100644 --- a/dScripts/ai/ACT/FootRace/BaseFootRaceManager.cpp +++ b/dScripts/ai/ACT/FootRace/BaseFootRaceManager.cpp @@ -37,7 +37,7 @@ void BaseFootRaceManager::OnFireEventServerSide(Entity* self, Entity* sender, st if (character != nullptr) { character->SetPlayerFlag(115, false); if (param2 != -1) // Certain footraces set a flag - character->SetPlayerFlag(param2, true); + character->SetPlayerFlag(static_cast(param2), true); } StopActivity(self, player->GetObjectID(), 0, param1); diff --git a/dScripts/ai/AG/AgJetEffectServer.cpp b/dScripts/ai/AG/AgJetEffectServer.cpp index 37e2e573..0a26069e 100644 --- a/dScripts/ai/AG/AgJetEffectServer.cpp +++ b/dScripts/ai/AG/AgJetEffectServer.cpp @@ -6,113 +6,55 @@ #include "RenderComponent.h" void AgJetEffectServer::OnUse(Entity* self, Entity* user) { - if (inUse) { - return; - } - + if (inUse || self->GetLOT() != 6859) return; GameMessages::SendNotifyClientObject( - self->GetObjectID(), - u"isInUse", - 0, - 0, - LWOOBJID_EMPTY, - "", - UNASSIGNED_SYSTEM_ADDRESS + self->GetObjectID(), u"toggleInUse", 1, 0, LWOOBJID_EMPTY, "", UNASSIGNED_SYSTEM_ADDRESS ); - inUse = true; auto entities = EntityManager::Instance()->GetEntitiesInGroup("Jet_FX"); - - if (entities.empty()) { - return; - } - - auto* effect = entities[0]; - - GameMessages::SendPlayFXEffect(effect, 641, u"create", "radarDish", LWOOBJID_EMPTY, 1, 1, true); - - self->AddTimer("radarDish", 2); - self->AddTimer("CineDone", 9); + if (entities.empty()) return; + GameMessages::SendPlayFXEffect(entities.at(0), 641, u"create", "radarDish", LWOOBJID_EMPTY, 1, 1, true); + self->AddTimer("radarDish", 2.0f); + self->AddTimer("PlayEffect", 2.5f); + self->AddTimer("CineDone", 7.5f + 5.0f); // 7.5f is time the cinematic takes to play } void AgJetEffectServer::OnRebuildComplete(Entity* self, Entity* target) { + if (self->GetLOT() != 6209) return; auto entities = EntityManager::Instance()->GetEntitiesInGroup("Jet_FX"); + if (entities.empty()) return; + RenderComponent::PlayAnimation(entities.at(0), u"jetFX"); - if (entities.empty()) { - return; - } - - auto* effect = entities[0]; - - auto groups = self->GetGroups(); - - if (groups.empty()) { - return; - } - + // So we can give kill credit to person who build this builder = target->GetObjectID(); - const auto group = groups[0]; - - RenderComponent::PlayAnimation(effect, u"jetFX"); - - self->AddTimer("PlayEffect", 2.5f); - - if (group == "Base_Radar") { - self->AddTimer("CineDone", 5); + auto groups = self->GetGroups(); + if (!groups.empty() && groups.at(0) == "Base_Radar") { + self->AddTimer("PlayEffect", 2.5f); + self->AddTimer("CineDone", 7.5f + 5.0f); // 7.5f is time the cinematic takes to play } } void AgJetEffectServer::OnTimerDone(Entity* self, std::string timerName) { if (timerName == "radarDish") { GameMessages::SendStopFXEffect(self, true, "radarDish"); - - return; - } - - if (timerName == "PlayEffect") { + } else if (timerName == "PlayEffect") { auto entities = EntityManager::Instance()->GetEntitiesInGroup("mortarMain"); + if (entities.empty()) return; - if (entities.empty()) { - return; - } - - const auto size = entities.size(); - - if (size == 0) { - return; - } - - const auto selected = GeneralUtils::GenerateRandomNumber(0, size - 1); - - auto* mortar = entities[selected]; - - Game::logger->Log("AgJetEffectServer", "Mortar (%i) (&d)", mortar->GetLOT(), mortar->HasComponent(eReplicaComponentType::SKILL)); + const auto selected = GeneralUtils::GenerateRandomNumber(0, entities.size() - 1); + auto* mortar = entities.at(selected); + // so we give proper credit to the builder for the kills from this skill mortar->SetOwnerOverride(builder); - SkillComponent* skillComponent; - if (!mortar->TryGetComponent(eReplicaComponentType::SKILL, skillComponent)) { - return; - } - - skillComponent->CalculateBehavior(318, 3727, LWOOBJID_EMPTY, true); - - return; - } - - if (timerName == "CineDone") { + auto* skillComponent = mortar->GetComponent(); + if (skillComponent) skillComponent->CastSkill(318); + } else if (timerName == "CineDone") { GameMessages::SendNotifyClientObject( - self->GetObjectID(), - u"toggleInUse", - -1, - 0, - LWOOBJID_EMPTY, - "", - UNASSIGNED_SYSTEM_ADDRESS + self->GetObjectID(), u"toggleInUse", -1, 0, LWOOBJID_EMPTY, "", UNASSIGNED_SYSTEM_ADDRESS ); - inUse = false; } } diff --git a/dScripts/ai/AG/AgPicnicBlanket.cpp b/dScripts/ai/AG/AgPicnicBlanket.cpp index d2a54d57..bec5577c 100644 --- a/dScripts/ai/AG/AgPicnicBlanket.cpp +++ b/dScripts/ai/AG/AgPicnicBlanket.cpp @@ -2,9 +2,10 @@ #include "Loot.h" #include "GameMessages.h" #include "Entity.h" +#include "eTerminateType.h" void AgPicnicBlanket::OnUse(Entity* self, Entity* user) { - GameMessages::SendTerminateInteraction(user->GetObjectID(), FROM_INTERACTION, self->GetObjectID()); + GameMessages::SendTerminateInteraction(user->GetObjectID(), eTerminateType::FROM_INTERACTION, self->GetObjectID()); if (self->GetVar(u"active")) return; self->SetVar(u"active", true); diff --git a/dScripts/ai/AG/AgQbElevator.cpp b/dScripts/ai/AG/AgQbElevator.cpp index f1ac7bb5..e1d78a21 100644 --- a/dScripts/ai/AG/AgQbElevator.cpp +++ b/dScripts/ai/AG/AgQbElevator.cpp @@ -49,7 +49,7 @@ void AgQbElevator::OnTimerDone(Entity* self, std::string timerName) { } else if (timerName == "startKillTimer") { killTimerStartup(self); } else if (timerName == "KillTimer") { - self->Smash(self->GetObjectID(), VIOLENT); + self->Smash(self->GetObjectID(), eKillType::VIOLENT); } } diff --git a/dScripts/ai/AG/AgShipPlayerShockServer.cpp b/dScripts/ai/AG/AgShipPlayerShockServer.cpp index 0eb1d9c8..e14d48ae 100644 --- a/dScripts/ai/AG/AgShipPlayerShockServer.cpp +++ b/dScripts/ai/AG/AgShipPlayerShockServer.cpp @@ -2,6 +2,7 @@ #include "GameMessages.h" #include "RenderComponent.h" #include "Entity.h" +#include "eTerminateType.h" void AgShipPlayerShockServer::OnUse(Entity* self, Entity* user) { GameMessages::SendTerminateInteraction(user->GetObjectID(), eTerminateType::FROM_INTERACTION, self->GetObjectID()); diff --git a/dScripts/ai/FV/ActNinjaSensei.cpp b/dScripts/ai/FV/ActNinjaSensei.cpp new file mode 100644 index 00000000..27e42219 --- /dev/null +++ b/dScripts/ai/FV/ActNinjaSensei.cpp @@ -0,0 +1,78 @@ +#include "ActNinjaSensei.h" +#include "Entity.h" +#include "EntityManager.h" +#include "GameMessages.h" + +void ActNinjaSensei::OnStartup(Entity* self) { + auto students = EntityManager::Instance()->GetEntitiesInGroup(this->m_StudentGroup); + std::vector validStudents = {}; + for (auto* student : students) { + if (student && student->GetLOT() == this->m_StudentLOT) validStudents.push_back(student); + } + self->SetVar(u"students", validStudents); + self->AddTimer("crane", 5); +} + +void ActNinjaSensei::OnTimerDone(Entity* self, std::string timerName) { + auto students = self->GetVar>(u"students"); + if (students.empty()) return; + + if (timerName == "crane") { + for (auto student : students) { + if (student) GameMessages::SendPlayAnimation(student, u"crane"); + } + GameMessages::SendPlayAnimation(self, u"crane"); + self->AddTimer("bow", 15.33); + } + + if (timerName == "bow") { + GameMessages::SendPlayAnimation(self, u"bow"); + for (auto student : students) { + if (student) GameMessages::SendPlayAnimation(student, u"bow"); + } + GameMessages::SendPlayAnimation(self, u"bow"); + self->AddTimer("tiger", 5); + } + + if (timerName == "tiger") { + GameMessages::SendPlayAnimation(self, u"tiger"); + for (auto student : students) { + if (student) GameMessages::SendPlayAnimation(student, u"tiger"); + } + GameMessages::SendPlayAnimation(self, u"tiger"); + self->AddTimer("bow2", 15.33); + } + + if (timerName == "bow2") { + GameMessages::SendPlayAnimation(self, u"bow"); + for (auto student : students) { + if (student) GameMessages::SendPlayAnimation(student, u"bow"); + } + GameMessages::SendPlayAnimation(self, u"bow"); + self->AddTimer("mantis", 5); + } + + if (timerName == "mantis") { + GameMessages::SendPlayAnimation(self, u"mantis"); + for (auto student : students) { + if (student) GameMessages::SendPlayAnimation(student, u"mantis"); + } + GameMessages::SendPlayAnimation(self, u"mantis"); + self->AddTimer("bow3", 15.3); + } + + if (timerName == "bow3") { + GameMessages::SendPlayAnimation(self, u"bow"); + for (auto student : students) { + if (student) GameMessages::SendPlayAnimation(student, u"bow"); + } + GameMessages::SendPlayAnimation(self, u"bow"); + self->AddTimer("repeat", 5); + } + + if (timerName == "repeat") { + self->CancelAllTimers(); + self->AddTimer("crane", 5); + } +} + diff --git a/dScripts/ai/FV/ActNinjaSensei.h b/dScripts/ai/FV/ActNinjaSensei.h new file mode 100644 index 00000000..c35ede12 --- /dev/null +++ b/dScripts/ai/FV/ActNinjaSensei.h @@ -0,0 +1,10 @@ +#pragma once +#include "CppScripts.h" + +class ActNinjaSensei : public CppScripts::Script { + void OnStartup(Entity* self) override; + void OnTimerDone(Entity* self, std::string timerName) override; +private: + std::string m_StudentGroup = "Sensei_kids"; + LOT m_StudentLOT = 2497; +}; diff --git a/dScripts/ai/FV/ActNinjaTurret.cpp b/dScripts/ai/FV/ActNinjaTurret.cpp index 79e502b4..ea6e2278 100644 --- a/dScripts/ai/FV/ActNinjaTurret.cpp +++ b/dScripts/ai/FV/ActNinjaTurret.cpp @@ -1,9 +1,10 @@ #include "ActNinjaTurret.h" +#include "eRebuildState.h" void ActNinjaTurret::OnRebuildNotifyState(Entity* self, eRebuildState state) { - if (state == eRebuildState::REBUILD_COMPLETED) { + if (state == eRebuildState::COMPLETED) { self->SetVar(u"AmBuilt", true); - } else if (state == eRebuildState::REBUILD_RESETTING) { + } else if (state == eRebuildState::RESETTING) { self->SetVar(u"AmBuilt", false); } } diff --git a/dScripts/ai/FV/ActParadoxPipeFix.cpp b/dScripts/ai/FV/ActParadoxPipeFix.cpp index 517474a9..10a1e652 100644 --- a/dScripts/ai/FV/ActParadoxPipeFix.cpp +++ b/dScripts/ai/FV/ActParadoxPipeFix.cpp @@ -21,7 +21,7 @@ void ActParadoxPipeFix::OnRebuildComplete(Entity* self, Entity* target) { auto* rebuildComponent = object->GetComponent(); - if (rebuildComponent->GetState() == REBUILD_COMPLETED) { + if (rebuildComponent->GetState() == eRebuildState::COMPLETED) { indexCount++; } } @@ -52,7 +52,7 @@ void ActParadoxPipeFix::OnRebuildComplete(Entity* self, Entity* target) { } void ActParadoxPipeFix::OnRebuildNotifyState(Entity* self, eRebuildState state) { - if (state == REBUILD_RESETTING) { + if (state == eRebuildState::RESETTING) { const auto refinery = EntityManager::Instance()->GetEntitiesInGroup("Paradox"); if (!refinery.empty()) { diff --git a/dScripts/ai/FV/CMakeLists.txt b/dScripts/ai/FV/CMakeLists.txt index 2a8a3367..56418706 100644 --- a/dScripts/ai/FV/CMakeLists.txt +++ b/dScripts/ai/FV/CMakeLists.txt @@ -1,4 +1,5 @@ -set(DSCRIPTS_SOURCES_AI_FV +set(DSCRIPTS_SOURCES_AI_FV + "ActNinjaSensei.cpp" "ActNinjaTurret.cpp" "FvFlyingCreviceDragon.cpp" "FvDragonSmashingGolemQb.cpp" @@ -15,4 +16,5 @@ set(DSCRIPTS_SOURCES_AI_FV "FvPassThroughWall.cpp" "FvBounceOverWall.cpp" "FvMaelstromGeyser.cpp" + "TriggerGas.cpp" PARENT_SCOPE) diff --git a/dScripts/ai/FV/FvBrickPuzzleServer.cpp b/dScripts/ai/FV/FvBrickPuzzleServer.cpp index cea6146b..887b9a4d 100644 --- a/dScripts/ai/FV/FvBrickPuzzleServer.cpp +++ b/dScripts/ai/FV/FvBrickPuzzleServer.cpp @@ -61,8 +61,8 @@ void FvBrickPuzzleServer::OnTimerDone(Entity* self, std::string timerName) { if (timerName == "reset") { auto* rebuildComponent = self->GetComponent(); - if (rebuildComponent != nullptr && rebuildComponent->GetState() == REBUILD_OPEN) { - self->Smash(self->GetObjectID(), SILENT); + if (rebuildComponent != nullptr && rebuildComponent->GetState() == eRebuildState::OPEN) { + self->Smash(self->GetObjectID(), eKillType::SILENT); } } } diff --git a/dScripts/ai/FV/FvConsoleLeftQuickbuild.cpp b/dScripts/ai/FV/FvConsoleLeftQuickbuild.cpp index b998b9ec..3f495ed7 100644 --- a/dScripts/ai/FV/FvConsoleLeftQuickbuild.cpp +++ b/dScripts/ai/FV/FvConsoleLeftQuickbuild.cpp @@ -1,6 +1,8 @@ #include "FvConsoleLeftQuickbuild.h" #include "EntityManager.h" #include "GameMessages.h" +#include "eTerminateType.h" +#include "eRebuildState.h" void FvConsoleLeftQuickbuild::OnStartup(Entity* self) { self->SetVar(u"IAmBuilt", false); @@ -8,7 +10,7 @@ void FvConsoleLeftQuickbuild::OnStartup(Entity* self) { } void FvConsoleLeftQuickbuild::OnRebuildNotifyState(Entity* self, eRebuildState state) { - if (state == REBUILD_COMPLETED) { + if (state == eRebuildState::COMPLETED) { self->SetVar(u"IAmBuilt", true); const auto objects = EntityManager::Instance()->GetEntitiesInGroup("Facility"); @@ -16,7 +18,7 @@ void FvConsoleLeftQuickbuild::OnRebuildNotifyState(Entity* self, eRebuildState s if (!objects.empty()) { objects[0]->NotifyObject(self, "ConsoleLeftUp"); } - } else if (state == REBUILD_RESETTING) { + } else if (state == eRebuildState::RESETTING) { self->SetVar(u"IAmBuilt", false); self->SetVar(u"AmActive", false); @@ -43,5 +45,5 @@ void FvConsoleLeftQuickbuild::OnUse(Entity* self, Entity* user) { } } - GameMessages::SendTerminateInteraction(user->GetObjectID(), FROM_INTERACTION, self->GetObjectID()); + GameMessages::SendTerminateInteraction(user->GetObjectID(), eTerminateType::FROM_INTERACTION, self->GetObjectID()); } diff --git a/dScripts/ai/FV/FvConsoleRightQuickbuild.cpp b/dScripts/ai/FV/FvConsoleRightQuickbuild.cpp index ea047cd8..e03e4135 100644 --- a/dScripts/ai/FV/FvConsoleRightQuickbuild.cpp +++ b/dScripts/ai/FV/FvConsoleRightQuickbuild.cpp @@ -1,6 +1,8 @@ #include "FvConsoleRightQuickbuild.h" #include "EntityManager.h" #include "GameMessages.h" +#include "eTerminateType.h" +#include "eRebuildState.h" void FvConsoleRightQuickbuild::OnStartup(Entity* self) { self->SetVar(u"IAmBuilt", false); @@ -8,7 +10,7 @@ void FvConsoleRightQuickbuild::OnStartup(Entity* self) { } void FvConsoleRightQuickbuild::OnRebuildNotifyState(Entity* self, eRebuildState state) { - if (state == REBUILD_COMPLETED) { + if (state == eRebuildState::COMPLETED) { self->SetVar(u"IAmBuilt", true); const auto objects = EntityManager::Instance()->GetEntitiesInGroup("Facility"); @@ -16,7 +18,7 @@ void FvConsoleRightQuickbuild::OnRebuildNotifyState(Entity* self, eRebuildState if (!objects.empty()) { objects[0]->NotifyObject(self, "ConsoleRightUp"); } - } else if (state == REBUILD_RESETTING) { + } else if (state == eRebuildState::RESETTING) { self->SetVar(u"IAmBuilt", false); self->SetVar(u"AmActive", false); @@ -43,5 +45,5 @@ void FvConsoleRightQuickbuild::OnUse(Entity* self, Entity* user) { } } - GameMessages::SendTerminateInteraction(user->GetObjectID(), FROM_INTERACTION, self->GetObjectID()); + GameMessages::SendTerminateInteraction(user->GetObjectID(), eTerminateType::FROM_INTERACTION, self->GetObjectID()); } diff --git a/dScripts/ai/FV/FvDragonSmashingGolemQb.cpp b/dScripts/ai/FV/FvDragonSmashingGolemQb.cpp index d46173fd..8f2133a9 100644 --- a/dScripts/ai/FV/FvDragonSmashingGolemQb.cpp +++ b/dScripts/ai/FV/FvDragonSmashingGolemQb.cpp @@ -3,6 +3,7 @@ #include "EntityManager.h" #include "RenderComponent.h" #include "Entity.h" +#include "eRebuildState.h" void FvDragonSmashingGolemQb::OnStartup(Entity* self) { self->AddTimer("GolemBreakTimer", 10.5f); @@ -15,7 +16,7 @@ void FvDragonSmashingGolemQb::OnTimerDone(Entity* self, std::string timerName) { } void FvDragonSmashingGolemQb::OnRebuildNotifyState(Entity* self, eRebuildState state) { - if (state == eRebuildState::REBUILD_COMPLETED) { + if (state == eRebuildState::COMPLETED) { RenderComponent::PlayAnimation(self, u"dragonsmash"); const auto dragonId = self->GetVar(u"Dragon"); diff --git a/dScripts/ai/FV/FvFacilityBrick.cpp b/dScripts/ai/FV/FvFacilityBrick.cpp index 1ae910e4..6ff12750 100644 --- a/dScripts/ai/FV/FvFacilityBrick.cpp +++ b/dScripts/ai/FV/FvFacilityBrick.cpp @@ -56,7 +56,7 @@ void FvFacilityBrick::OnNotifyObject(Entity* self, Entity* sender, const std::st object = EntityManager::Instance()->GetEntitiesInGroup("Canister")[0]; if (object != nullptr) { - object->Smash(self->GetObjectID(), SILENT); + object->Smash(self->GetObjectID(), eKillType::SILENT); } canisterSpawner->Reset(); diff --git a/dScripts/ai/FV/FvPandaServer.cpp b/dScripts/ai/FV/FvPandaServer.cpp index bea93a6c..f29f7f2e 100644 --- a/dScripts/ai/FV/FvPandaServer.cpp +++ b/dScripts/ai/FV/FvPandaServer.cpp @@ -1,6 +1,7 @@ #include "FvPandaServer.h" #include "PetComponent.h" #include "Character.h" +#include "ePetTamingNotifyType.h" void FvPandaServer::OnStartup(Entity* self) { const auto* petComponent = self->GetComponent(); @@ -10,12 +11,12 @@ void FvPandaServer::OnStartup(Entity* self) { } } -void FvPandaServer::OnNotifyPetTamingMinigame(Entity* self, Entity* tamer, eNotifyType type) { - if (type == NOTIFY_TYPE_BEGIN) { +void FvPandaServer::OnNotifyPetTamingMinigame(Entity* self, Entity* tamer, ePetTamingNotifyType type) { + if (type == ePetTamingNotifyType::BEGIN) { self->CancelAllTimers(); - } else if (type == NOTIFY_TYPE_QUIT || type == NOTIFY_TYPE_FAILED) { + } else if (type == ePetTamingNotifyType::QUIT || type == ePetTamingNotifyType::FAILED) { self->Smash(); - } else if (type == NOTIFY_TYPE_SUCCESS) { + } else if (type == ePetTamingNotifyType::SUCCESS) { // TODO: Remove from groups auto* character = tamer->GetCharacter(); @@ -29,7 +30,7 @@ void FvPandaServer::OnTimerDone(Entity* self, std::string timerName) { if (timerName == "killSelf") { const auto* petComponent = self->GetComponent(); if (petComponent != nullptr && petComponent->GetOwner() == nullptr) { - self->Smash(self->GetObjectID(), SILENT); + self->Smash(self->GetObjectID(), eKillType::SILENT); } } } diff --git a/dScripts/ai/FV/FvPandaServer.h b/dScripts/ai/FV/FvPandaServer.h index 4948fdf4..5db060a0 100644 --- a/dScripts/ai/FV/FvPandaServer.h +++ b/dScripts/ai/FV/FvPandaServer.h @@ -3,6 +3,6 @@ class FvPandaServer : public CppScripts::Script { void OnStartup(Entity* self) override; - void OnNotifyPetTamingMinigame(Entity* self, Entity* tamer, eNotifyType type) override; + void OnNotifyPetTamingMinigame(Entity* self, Entity* tamer, ePetTamingNotifyType type) override; void OnTimerDone(Entity* self, std::string timerName) override; }; diff --git a/dScripts/ai/FV/TriggerGas.cpp b/dScripts/ai/FV/TriggerGas.cpp new file mode 100644 index 00000000..7e9762e3 --- /dev/null +++ b/dScripts/ai/FV/TriggerGas.cpp @@ -0,0 +1,49 @@ +#include "TriggerGas.h" +#include "InventoryComponent.h" +#include "SkillComponent.h" +#include "Entity.h" +#include "dLogger.h" + + +void TriggerGas::OnStartup(Entity* self) { + self->AddTimer(this->m_TimerName, this->m_Time); +} + +void TriggerGas::OnCollisionPhantom(Entity* self, Entity* target) { + if (!target->IsPlayer()) return; + auto players = self->GetVar>(u"players"); + players.push_back(target); + self->SetVar(u"players", players); +} + +void TriggerGas::OnOffCollisionPhantom(Entity* self, Entity* target) { + auto players = self->GetVar>(u"players"); + if (!target->IsPlayer() || players.empty()) return; + auto position = std::find(players.begin(), players.end(), target); + if (position != players.end()) players.erase(position); + self->SetVar(u"players", players); +} + +void TriggerGas::OnTimerDone(Entity* self, std::string timerName) { + if (timerName != this->m_TimerName) return; + auto players = self->GetVar>(u"players"); + for (auto player : players) { + if (player->GetIsDead() || !player){ + auto position = std::find(players.begin(), players.end(), player); + if (position != players.end()) players.erase(position); + continue; + } + auto inventoryComponent = player->GetComponent(); + if (inventoryComponent) { + if (!inventoryComponent->IsEquipped(this->m_MaelstromHelmet)) { + auto* skillComponent = self->GetComponent(); + if (skillComponent) { + skillComponent->CastSkill(this->m_FogDamageSkill, player->GetObjectID()); + } + } + } + } + self->SetVar(u"players", players); + self->AddTimer(this->m_TimerName, this->m_Time); +} + diff --git a/dScripts/ai/FV/TriggerGas.h b/dScripts/ai/FV/TriggerGas.h new file mode 100644 index 00000000..284f2485 --- /dev/null +++ b/dScripts/ai/FV/TriggerGas.h @@ -0,0 +1,14 @@ +#pragma once +#include "CppScripts.h" + +class TriggerGas : public CppScripts::Script { + void OnStartup(Entity* self) override; + void OnCollisionPhantom(Entity* self, Entity* target) override; + void OnOffCollisionPhantom(Entity* self, Entity* target) override; + void OnTimerDone(Entity* self, std::string timerName) override; +private: + std::string m_TimerName = "gasTriggerDamage"; + float m_Time = 3.0f; + uint32_t m_MaelstromHelmet = 3068; + uint32_t m_FogDamageSkill = 103; +}; diff --git a/dScripts/ai/GENERAL/InstanceExitTransferPlayerToLastNonInstance.cpp b/dScripts/ai/GENERAL/InstanceExitTransferPlayerToLastNonInstance.cpp index 4e42e7fb..de1c62e0 100644 --- a/dScripts/ai/GENERAL/InstanceExitTransferPlayerToLastNonInstance.cpp +++ b/dScripts/ai/GENERAL/InstanceExitTransferPlayerToLastNonInstance.cpp @@ -3,6 +3,7 @@ #include "Player.h" #include "Character.h" #include "dServer.h" +#include "eTerminateType.h" void InstanceExitTransferPlayerToLastNonInstance::OnUse(Entity* self, Entity* user) { auto transferText = self->GetVar(u"transferText"); diff --git a/dScripts/ai/GENERAL/LegoDieRoll.cpp b/dScripts/ai/GENERAL/LegoDieRoll.cpp index add3cd06..763a4704 100644 --- a/dScripts/ai/GENERAL/LegoDieRoll.cpp +++ b/dScripts/ai/GENERAL/LegoDieRoll.cpp @@ -12,7 +12,7 @@ void LegoDieRoll::OnStartup(Entity* self) { void LegoDieRoll::OnTimerDone(Entity* self, std::string timerName) { if (timerName == "DoneRolling") { - self->Smash(self->GetObjectID(), SILENT); + self->Smash(self->GetObjectID(), eKillType::SILENT); } else if (timerName == "ThrowDice") { int dieRoll = GeneralUtils::GenerateRandomNumber(1, 6); diff --git a/dScripts/ai/GF/GfJailWalls.cpp b/dScripts/ai/GF/GfJailWalls.cpp index 56710832..1835faa2 100644 --- a/dScripts/ai/GF/GfJailWalls.cpp +++ b/dScripts/ai/GF/GfJailWalls.cpp @@ -1,6 +1,7 @@ #include "GfJailWalls.h" #include "dZoneManager.h" #include "GeneralUtils.h" +#include "eRebuildState.h" void GfJailWalls::OnRebuildComplete(Entity* self, Entity* target) { const auto wall = GeneralUtils::UTF16ToWTF8(self->GetVar(u"Wall")); @@ -15,7 +16,7 @@ void GfJailWalls::OnRebuildComplete(Entity* self, Entity* target) { } void GfJailWalls::OnRebuildNotifyState(Entity* self, eRebuildState state) { - if (state != eRebuildState::REBUILD_RESETTING) return; + if (state != eRebuildState::RESETTING) return; const auto wall = GeneralUtils::UTF16ToWTF8(self->GetVar(u"Wall")); diff --git a/dScripts/ai/GF/PetDigBuild.cpp b/dScripts/ai/GF/PetDigBuild.cpp index 2c3da9fc..504a1199 100644 --- a/dScripts/ai/GF/PetDigBuild.cpp +++ b/dScripts/ai/GF/PetDigBuild.cpp @@ -46,6 +46,6 @@ void PetDigBuild::OnDie(Entity* self, Entity* killer) { // If the quick build expired and the treasure was not collected, hide the treasure if (!treasure->GetIsDead()) { - treasure->Smash(self->GetObjectID(), SILENT); + treasure->Smash(self->GetObjectID(), eKillType::SILENT); } } diff --git a/dScripts/ai/GF/PirateRep.cpp b/dScripts/ai/GF/PirateRep.cpp index ccfa7af6..33d6ab63 100644 --- a/dScripts/ai/GF/PirateRep.cpp +++ b/dScripts/ai/GF/PirateRep.cpp @@ -2,12 +2,13 @@ #include "Character.h" #include "eMissionState.h" #include "Entity.h" +#include "ePlayerFlag.h" void PirateRep::OnMissionDialogueOK(Entity* self, Entity* target, int missionID, eMissionState missionState) { if (missionID == m_PirateRepMissionID && missionState >= eMissionState::READY_TO_COMPLETE) { auto* character = target->GetCharacter(); if (character) { - character->SetPlayerFlag(ePlayerFlags::GF_PIRATE_REP, true); + character->SetPlayerFlag(ePlayerFlag::GF_PIRATE_REP, true); } } } diff --git a/dScripts/ai/MINIGAME/SG_GF/SERVER/SGCannon.cpp b/dScripts/ai/MINIGAME/SG_GF/SERVER/SGCannon.cpp index a62f6ee5..9543504a 100644 --- a/dScripts/ai/MINIGAME/SG_GF/SERVER/SGCannon.cpp +++ b/dScripts/ai/MINIGAME/SG_GF/SERVER/SGCannon.cpp @@ -16,6 +16,7 @@ #include "eMissionTaskType.h" #include "eReplicaComponentType.h" #include "RenderComponent.h" +#include "eGameActivity.h" void SGCannon::OnStartup(Entity* self) { Game::logger->Log("SGCannon", "OnStartup"); @@ -103,7 +104,7 @@ void SGCannon::OnActivityStateChangeRequest(Entity* self, LWOOBJID senderID, int if (characterComponent != nullptr) { characterComponent->SetIsRacing(true); - characterComponent->SetCurrentActivity(2); + characterComponent->SetCurrentActivity(eGameActivity::SHOOTING_GALLERY); auto possessor = player->GetComponent(); if (possessor) { possessor->SetPossessable(self->GetObjectID()); @@ -135,38 +136,26 @@ void SGCannon::OnActivityStateChangeRequest(Entity* self, LWOOBJID senderID, int } } -void SGCannon::OnMessageBoxResponse(Entity* self, Entity* sender, int32_t button, const std::u16string& identifier, - const std::u16string& userData) { +void SGCannon::OnMessageBoxResponse(Entity* self, Entity* sender, int32_t button, const std::u16string& identifier, const std::u16string& userData) { auto* player = EntityManager::Instance()->GetEntity(self->GetVar(PlayerIDVariable)); - if (player != nullptr) { - if (button == 1 && identifier == u"Shooting_Gallery_Stop") { + if (!player) return; + + if (identifier == u"Scoreboardinfo") { + GameMessages::SendDisplayMessageBox(player->GetObjectID(), true, + dZoneManager::Instance()->GetZoneControlObject()->GetObjectID(), + u"Shooting_Gallery_Retry", 2, u"Retry?", + u"", player->GetSystemAddress()); + } else { + if ((button == 1 && (identifier == u"Shooting_Gallery_Retry" || identifier == u"RePlay")) || identifier == u"SG1" || button == 0) { + if (IsPlayerInActivity(self, player->GetObjectID())) return; + self->SetNetworkVar(ClearVariable, true); + StartGame(self); + } else if (button == 0 && ((identifier == u"Shooting_Gallery_Retry" || identifier == u"RePlay"))){ + RemovePlayer(player->GetObjectID()); + UpdatePlayer(self, player->GetObjectID(), true); + } else if (button == 1 && identifier == u"Shooting_Gallery_Exit") { UpdatePlayer(self, player->GetObjectID(), true); RemovePlayer(player->GetObjectID()); - StopGame(self, true); - return; - } - - if (identifier == u"Scoreboardinfo") { - GameMessages::SendDisplayMessageBox(player->GetObjectID(), true, - dZoneManager::Instance()->GetZoneControlObject()->GetObjectID(), - u"Shooting_Gallery_Retry?", 2, u"Retry?", - u"", player->GetSystemAddress()); - } else { - if ((button == 1 && (identifier == u"Shooting_Gallery_Retry" || identifier == u"RePlay")) - || identifier == u"SG1" || button == 0) { - - if (identifier == u"RePlay") { - static_cast(player)->SendToZone(1300); - - return; - } - - self->SetNetworkVar(ClearVariable, true); - StartGame(self); - } else if (button == 1 && identifier == u"Shooting_Gallery_Exit") { - UpdatePlayer(self, player->GetObjectID(), true); - RemovePlayer(player->GetObjectID()); - } } } } @@ -267,13 +256,17 @@ void SGCannon::OnActivityTimerDone(Entity* self, const std::string& name) { if (self->GetVar(GameStartedVariable)) { const auto spawnNumber = (uint32_t)std::stoi(name.substr(7)); const auto& activeSpawns = self->GetVar>(ActiveSpawnsVariable); + if (activeSpawns.size() < spawnNumber) { + Game::logger->Log("SGCannon", "Trying to spawn %i when spawns size is only %i", spawnNumber, activeSpawns.size()); + return; + } const auto& toSpawn = activeSpawns.at(spawnNumber); - const auto pathIndex = GeneralUtils::GenerateRandomNumber(0, toSpawn.spawnPaths.size() - 1); - - const auto* path = dZoneManager::Instance()->GetZone()->GetPath( - toSpawn.spawnPaths.at(pathIndex) - ); + const auto* path = dZoneManager::Instance()->GetZone()->GetPath(toSpawn.spawnPaths.at(pathIndex)); + if (!path) { + Game::logger->Log("SGCannon", "Path %s at index %i is null", toSpawn.spawnPaths.at(pathIndex).c_str(), pathIndex); + return; + } auto info = EntityInfo{}; info.lot = toSpawn.lot; @@ -294,32 +287,30 @@ void SGCannon::OnActivityTimerDone(Entity* self, const std::string& name) { auto* enemy = EntityManager::Instance()->CreateEntity(info, nullptr, self); EntityManager::Instance()->ConstructEntity(enemy); - if (true) { - auto* movementAI = new MovementAIComponent(enemy, {}); + auto* movementAI = new MovementAIComponent(enemy, {}); - enemy->AddComponent(eReplicaComponentType::MOVEMENT_AI, movementAI); + enemy->AddComponent(eReplicaComponentType::MOVEMENT_AI, movementAI); - movementAI->SetSpeed(toSpawn.initialSpeed); - movementAI->SetCurrentSpeed(toSpawn.initialSpeed); - movementAI->SetHaltDistance(0.0f); + movementAI->SetSpeed(toSpawn.initialSpeed); + movementAI->SetCurrentSpeed(toSpawn.initialSpeed); + movementAI->SetHaltDistance(0.0f); - std::vector pathWaypoints; + std::vector pathWaypoints; - for (const auto& waypoint : path->pathWaypoints) { - pathWaypoints.push_back(waypoint.position); - } - - if (GeneralUtils::GenerateRandomNumber(0, 1) < 0.5f) { - std::reverse(pathWaypoints.begin(), pathWaypoints.end()); - } - - movementAI->SetPath(pathWaypoints); - - enemy->AddDieCallback([this, self, enemy, name]() { - RegisterHit(self, enemy, name); - }); + for (const auto& waypoint : path->pathWaypoints) { + pathWaypoints.push_back(waypoint.position); } + if (GeneralUtils::GenerateRandomNumber(0, 1) < 0.5f) { + std::reverse(pathWaypoints.begin(), pathWaypoints.end()); + } + + movementAI->SetPath(pathWaypoints); + + enemy->AddDieCallback([this, self, enemy, name]() { + RegisterHit(self, enemy, name); + }); + // Save the enemy and tell it to start pathing if (enemy != nullptr) { const_cast&>(self->GetVar>(SpawnedObjects)).push_back(enemy->GetObjectID()); @@ -338,6 +329,7 @@ SGCannon::OnActivityTimerUpdate(Entity* self, const std::string& name, float_t t } void SGCannon::StartGame(Entity* self) { + if (self->GetVar(GameStartedVariable)) return; self->SetNetworkVar(TimeLimitVariable, self->GetVar(TimeLimitVariable)); self->SetNetworkVar(AudioStartIntroVariable, true); self->SetVar(CurrentRewardVariable, LOT_NULL); @@ -444,6 +436,14 @@ void SGCannon::RemovePlayer(LWOOBJID playerID) { } } +void SGCannon::OnRequestActivityExit(Entity* self, LWOOBJID player, bool canceled){ + if (canceled){ + StopGame(self, canceled); + RemovePlayer(player); + } +} + + void SGCannon::StartChargedCannon(Entity* self, uint32_t optionalTime) { optionalTime = optionalTime == 0 ? constants.chargedTime : optionalTime; self->SetVar(SuperChargePausedVariable, false); @@ -571,13 +571,13 @@ void SGCannon::StopGame(Entity* self, bool cancel) { auto* inventory = player->GetComponent(); if (inventory != nullptr) { for (const auto rewardLot : self->GetVar>(RewardsVariable)) { - inventory->AddItem(rewardLot, 1, eLootSourceType::LOOT_SOURCE_ACTIVITY, eInventoryType::MODELS); + inventory->AddItem(rewardLot, 1, eLootSourceType::ACTIVITY, eInventoryType::MODELS); } } self->SetNetworkVar(u"UI_Rewards", GeneralUtils::to_u16string(self->GetVar(TotalScoreVariable)) + u"_0_0_0_0_0_0" - ); + ); GameMessages::SendRequestActivitySummaryLeaderboardData( player->GetObjectID(), diff --git a/dScripts/ai/MINIGAME/SG_GF/SERVER/SGCannon.h b/dScripts/ai/MINIGAME/SG_GF/SERVER/SGCannon.h index df9831ad..b20fae6d 100644 --- a/dScripts/ai/MINIGAME/SG_GF/SERVER/SGCannon.h +++ b/dScripts/ai/MINIGAME/SG_GF/SERVER/SGCannon.h @@ -63,12 +63,11 @@ public: void OnStartup(Entity* self) override; void OnPlayerLoaded(Entity* self, Entity* player) override; void OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2, int32_t param3) override; - void OnActivityStateChangeRequest(Entity* self, LWOOBJID senderID, int32_t value1, - int32_t value2, const std::u16string& stringValue) override; - void OnMessageBoxResponse(Entity* self, Entity* sender, int32_t button, const std::u16string& identifier, - const std::u16string& userData) override; + void OnActivityStateChangeRequest(Entity* self, LWOOBJID senderID, int32_t value1, int32_t value2, const std::u16string& stringValue) override; + void OnMessageBoxResponse(Entity* self, Entity* sender, int32_t button, const std::u16string& identifier, const std::u16string& userData) override; void OnActivityTimerDone(Entity* self, const std::string& name) override; void OnActivityTimerUpdate(Entity* self, const std::string& name, float_t timeRemaining, float_t elapsedTime) override; + void OnRequestActivityExit(Entity* self, LWOOBJID player, bool canceled) override; private: static std::vector> GetWaves(); static SGConstants GetConstants(); diff --git a/dScripts/ai/NS/NsConcertInstrument.cpp b/dScripts/ai/NS/NsConcertInstrument.cpp index 08464e5a..ba99d4d1 100644 --- a/dScripts/ai/NS/NsConcertInstrument.cpp +++ b/dScripts/ai/NS/NsConcertInstrument.cpp @@ -21,7 +21,7 @@ void NsConcertInstrument::OnStartup(Entity* self) { } void NsConcertInstrument::OnRebuildNotifyState(Entity* self, eRebuildState state) { - if (state == REBUILD_RESETTING || state == REBUILD_OPEN) { + if (state == eRebuildState::RESETTING || state == eRebuildState::OPEN) { self->SetVar(u"activePlayer", LWOOBJID_EMPTY); } } @@ -97,7 +97,7 @@ void NsConcertInstrument::OnTimerDone(Entity* self, std::string name) { if (rebuildComponent != nullptr) rebuildComponent->ResetRebuild(false); - self->Smash(self->GetObjectID(), VIOLENT); + self->Smash(self->GetObjectID(), eKillType::VIOLENT); self->SetVar(u"activePlayer", LWOOBJID_EMPTY); } else if (activePlayer != nullptr && name == "achievement") { auto* missionComponent = activePlayer->GetComponent(); @@ -200,7 +200,7 @@ void NsConcertInstrument::EquipInstruments(Entity* self, Entity* player) { // Equip the left hand instrument const auto leftInstrumentLot = instrumentLotLeft.find(GetInstrumentLot(self))->second; if (leftInstrumentLot != LOT_NULL) { - inventory->AddItem(leftInstrumentLot, 1, eLootSourceType::LOOT_SOURCE_NONE, TEMP_ITEMS, {}, LWOOBJID_EMPTY, false); + inventory->AddItem(leftInstrumentLot, 1, eLootSourceType::NONE, TEMP_ITEMS, {}, LWOOBJID_EMPTY, false); auto* leftInstrument = inventory->FindItemByLot(leftInstrumentLot, TEMP_ITEMS); leftInstrument->Equip(); } @@ -208,7 +208,7 @@ void NsConcertInstrument::EquipInstruments(Entity* self, Entity* player) { // Equip the right hand instrument const auto rightInstrumentLot = instrumentLotRight.find(GetInstrumentLot(self))->second; if (rightInstrumentLot != LOT_NULL) { - inventory->AddItem(rightInstrumentLot, 1, eLootSourceType::LOOT_SOURCE_NONE, TEMP_ITEMS, {}, LWOOBJID_EMPTY, false); + inventory->AddItem(rightInstrumentLot, 1, eLootSourceType::NONE, TEMP_ITEMS, {}, LWOOBJID_EMPTY, false); auto* rightInstrument = inventory->FindItemByLot(rightInstrumentLot, TEMP_ITEMS); rightInstrument->Equip(); } diff --git a/dScripts/ai/NS/NsConcertQuickBuild.cpp b/dScripts/ai/NS/NsConcertQuickBuild.cpp index fcec4dc7..4589ee6a 100644 --- a/dScripts/ai/NS/NsConcertQuickBuild.cpp +++ b/dScripts/ai/NS/NsConcertQuickBuild.cpp @@ -58,7 +58,7 @@ void NsConcertQuickBuild::OnStartup(Entity* self) { // Destroys the quick build after a while if it wasn't built self->AddCallbackTimer(resetActivatorTime, [self]() { self->SetNetworkVar(u"startEffect", -1.0f); - self->Smash(self->GetObjectID(), SILENT); + self->Smash(self->GetObjectID(), eKillType::SILENT); }); } diff --git a/dScripts/ai/NS/NsGetFactionMissionServer.cpp b/dScripts/ai/NS/NsGetFactionMissionServer.cpp index cfecb249..185bd344 100644 --- a/dScripts/ai/NS/NsGetFactionMissionServer.cpp +++ b/dScripts/ai/NS/NsGetFactionMissionServer.cpp @@ -3,6 +3,7 @@ #include "MissionComponent.h" #include "Character.h" #include "eReplicaComponentType.h" +#include "ePlayerFlag.h" void NsGetFactionMissionServer::OnRespondToMission(Entity* self, int missionID, Entity* player, int reward) { if (missionID != 474) return; @@ -10,7 +11,7 @@ void NsGetFactionMissionServer::OnRespondToMission(Entity* self, int missionID, if (reward != LOT_NULL) { std::vector factionMissions; int celebrationID = -1; - int flagID = -1; + int32_t flagID = -1; if (reward == 6980) { // Venture League @@ -41,7 +42,7 @@ void NsGetFactionMissionServer::OnRespondToMission(Entity* self, int missionID, } if (flagID != -1) { - player->GetCharacter()->SetPlayerFlag(ePlayerFlags::JOINED_A_FACTION, true); + player->GetCharacter()->SetPlayerFlag(ePlayerFlag::JOINED_A_FACTION, true); player->GetCharacter()->SetPlayerFlag(flagID, true); } diff --git a/dScripts/ai/PROPERTY/AgPropguards.cpp b/dScripts/ai/PROPERTY/AgPropguards.cpp index 9fc6010a..7e8e2fd1 100644 --- a/dScripts/ai/PROPERTY/AgPropguards.cpp +++ b/dScripts/ai/PROPERTY/AgPropguards.cpp @@ -39,7 +39,7 @@ void AgPropguards::OnMissionDialogueOK(Entity* self, Entity* target, int mission } } -uint32_t AgPropguards::GetFlagForMission(uint32_t missionID) { +int32_t AgPropguards::GetFlagForMission(uint32_t missionID) { switch (missionID) { case 872: return 97; diff --git a/dScripts/ai/PROPERTY/AgPropguards.h b/dScripts/ai/PROPERTY/AgPropguards.h index 25701f86..ed2e3cb0 100644 --- a/dScripts/ai/PROPERTY/AgPropguards.h +++ b/dScripts/ai/PROPERTY/AgPropguards.h @@ -4,5 +4,5 @@ class AgPropguards : public CppScripts::Script { void OnMissionDialogueOK(Entity* self, Entity* target, int missionID, eMissionState missionState) override; private: - static uint32_t GetFlagForMission(uint32_t missionID); + static int32_t GetFlagForMission(uint32_t missionID); }; diff --git a/dScripts/ai/SPEC/CMakeLists.txt b/dScripts/ai/SPEC/CMakeLists.txt index c4c5b809..42dbf8f8 100644 --- a/dScripts/ai/SPEC/CMakeLists.txt +++ b/dScripts/ai/SPEC/CMakeLists.txt @@ -1,3 +1,5 @@ -set(DSCRIPTS_SOURCES_AI_SPEC - "SpecialImaginePowerupSpawner.cpp" +set(DSCRIPTS_SOURCES_AI_SPEC + "SpecialCoinSpawner.cpp" + "SpecialPowerupSpawner.cpp" + "SpecialSpeedBuffSpawner.cpp" PARENT_SCOPE) diff --git a/dScripts/ai/SPEC/SpecialCoinSpawner.cpp b/dScripts/ai/SPEC/SpecialCoinSpawner.cpp new file mode 100644 index 00000000..ff494845 --- /dev/null +++ b/dScripts/ai/SPEC/SpecialCoinSpawner.cpp @@ -0,0 +1,16 @@ +#include "SpecialCoinSpawner.h" +#include "CharacterComponent.h" + +void SpecialCoinSpawner::OnStartup(Entity* self) { + self->SetProximityRadius(1.5f, "powerupEnter"); +} + +void SpecialCoinSpawner::OnProximityUpdate(Entity* self, Entity* entering, const std::string name, const std::string status) { + if (name != "powerupEnter" && status != "ENTER") return; + if (!entering->IsPlayer()) return; + auto character = entering->GetCharacter(); + if (!character) return; + GameMessages::SendPlayFXEffect(self, -1, u"pickup", "", LWOOBJID_EMPTY, 1, 1, true); + character->SetCoins(character->GetCoins() + this->m_CurrencyDenomination, eLootSourceType::CURRENCY); + self->Smash(entering->GetObjectID(), eKillType::SILENT); +} diff --git a/dScripts/ai/SPEC/SpecialCoinSpawner.h b/dScripts/ai/SPEC/SpecialCoinSpawner.h new file mode 100644 index 00000000..5af6f24a --- /dev/null +++ b/dScripts/ai/SPEC/SpecialCoinSpawner.h @@ -0,0 +1,13 @@ +#pragma once +#include "CppScripts.h" + +class SpecialCoinSpawner : public CppScripts::Script { +public: + SpecialCoinSpawner(uint32_t CurrencyDenomination) { + m_CurrencyDenomination = CurrencyDenomination; + }; + void OnStartup(Entity* self) override; + void OnProximityUpdate(Entity* self, Entity* entering, const std::string name, const std::string status) override; +private: + int32_t m_CurrencyDenomination = 0; +}; diff --git a/dScripts/ai/SPEC/SpecialImaginePowerupSpawner.cpp b/dScripts/ai/SPEC/SpecialImaginePowerupSpawner.cpp deleted file mode 100644 index 43ae9e89..00000000 --- a/dScripts/ai/SPEC/SpecialImaginePowerupSpawner.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include "SpecialImaginePowerupSpawner.h" - -#include "GameMessages.h" -#include "SkillComponent.h" -#include "DestroyableComponent.h" -#include "EntityManager.h" -#include "eReplicaComponentType.h" - -void SpecialImaginePowerupSpawner::OnStartup(Entity* self) { - self->SetProximityRadius(1.5f, "powerupEnter"); - self->SetVar(u"bIsDead", false); -} - -void SpecialImaginePowerupSpawner::OnProximityUpdate(Entity* self, Entity* entering, const std::string name, const std::string status) { - if (name != "powerupEnter" && status != "ENTER") { - return; - } - - if (entering->GetLOT() != 1) { - return; - } - - if (self->GetVar(u"bIsDead")) { - return; - } - - GameMessages::SendPlayFXEffect(self, -1, u"pickup", "", LWOOBJID_EMPTY, 1, 1, true); - - SkillComponent* skillComponent; - if (!self->TryGetComponent(eReplicaComponentType::SKILL, skillComponent)) { - return; - } - - const auto source = entering->GetObjectID(); - - skillComponent->CalculateBehavior(13, 20, source); - - DestroyableComponent* destroyableComponent; - if (!self->TryGetComponent(eReplicaComponentType::DESTROYABLE, destroyableComponent)) { - return; - } - - self->SetVar(u"bIsDead", true); - - self->AddCallbackTimer(1.0f, [self]() { - EntityManager::Instance()->ScheduleForKill(self); - }); -} diff --git a/dScripts/ai/SPEC/SpecialPowerupSpawner.cpp b/dScripts/ai/SPEC/SpecialPowerupSpawner.cpp new file mode 100644 index 00000000..72565923 --- /dev/null +++ b/dScripts/ai/SPEC/SpecialPowerupSpawner.cpp @@ -0,0 +1,26 @@ +#include "SpecialPowerupSpawner.h" + +#include "GameMessages.h" +#include "SkillComponent.h" +#include "EntityManager.h" +#include "eReplicaComponentType.h" + +void SpecialPowerupSpawner::OnStartup(Entity* self) { + self->SetProximityRadius(1.5f, "powerupEnter"); + self->SetVar(u"bIsDead", false); +} + +void SpecialPowerupSpawner::OnProximityUpdate(Entity* self, Entity* entering, const std::string name, const std::string status) { + if (name != "powerupEnter" && status != "ENTER") return; + if (!entering->IsPlayer()) return; + if (self->GetVar(u"bIsDead")) return; + + GameMessages::SendPlayFXEffect(self, -1, u"pickup", "", LWOOBJID_EMPTY, 1, 1, true); + + auto skillComponent = self->GetComponent(); + if (!skillComponent) return; + skillComponent->CastSkill(this->m_SkillId, entering->GetObjectID()); + + self->SetVar(u"bIsDead", true); + self->Smash(entering->GetObjectID(), eKillType::SILENT); +} diff --git a/dScripts/ai/SPEC/SpecialPowerupSpawner.h b/dScripts/ai/SPEC/SpecialPowerupSpawner.h new file mode 100644 index 00000000..b27e9789 --- /dev/null +++ b/dScripts/ai/SPEC/SpecialPowerupSpawner.h @@ -0,0 +1,13 @@ +#pragma once +#include "CppScripts.h" + +class SpecialPowerupSpawner : public CppScripts::Script { +public: + SpecialPowerupSpawner(uint32_t skillId) { + m_SkillId = skillId; + }; + void OnStartup(Entity* self) override; + void OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) override; +private: + uint32_t m_SkillId = 0; +}; diff --git a/dScripts/ai/SPEC/SpecialSpeedBuffSpawner.cpp b/dScripts/ai/SPEC/SpecialSpeedBuffSpawner.cpp new file mode 100644 index 00000000..d3109806 --- /dev/null +++ b/dScripts/ai/SPEC/SpecialSpeedBuffSpawner.cpp @@ -0,0 +1,26 @@ +#include "SpecialSpeedBuffSpawner.h" + +#include "GameMessages.h" +#include "SkillComponent.h" +#include "EntityManager.h" +#include "eReplicaComponentType.h" + +void SpecialSpeedBuffSpawner::OnStartup(Entity* self) { + self->SetProximityRadius(1.5f, "powerupEnter"); + self->SetVar(u"bIsDead", false); +} + +void SpecialSpeedBuffSpawner::OnProximityUpdate(Entity* self, Entity* entering, const std::string name, const std::string status) { + if (name != "powerupEnter" && status != "ENTER") return; + if (!entering->IsPlayer()) return; + if (self->GetVar(u"bIsDead")) return; + + GameMessages::SendPlayFXEffect(self, -1, u"pickup", "", LWOOBJID_EMPTY, 1, 1, true); + + auto skillComponent = entering->GetComponent(); + if (!skillComponent) return; + skillComponent->CastSkill(this->m_SkillId, entering->GetObjectID()); + + self->SetVar(u"bIsDead", true); + self->Smash(entering->GetObjectID(), eKillType::SILENT); +} diff --git a/dScripts/ai/SPEC/SpecialSpeedBuffSpawner.h b/dScripts/ai/SPEC/SpecialSpeedBuffSpawner.h new file mode 100644 index 00000000..e1741691 --- /dev/null +++ b/dScripts/ai/SPEC/SpecialSpeedBuffSpawner.h @@ -0,0 +1,10 @@ +#pragma once +#include "CppScripts.h" + +class SpecialSpeedBuffSpawner : public CppScripts::Script { +public: + void OnStartup(Entity* self) override; + void OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) override; +private: + uint32_t m_SkillId = 500; +}; diff --git a/dScripts/ai/WILD/CMakeLists.txt b/dScripts/ai/WILD/CMakeLists.txt index 57470f72..446ce0d4 100644 --- a/dScripts/ai/WILD/CMakeLists.txt +++ b/dScripts/ai/WILD/CMakeLists.txt @@ -1,4 +1,11 @@ -set(DSCRIPTS_SOURCES_AI_WILD +set(DSCRIPTS_SOURCES_AI_WILD "AllCrateChicken.cpp" "WildAmbients.cpp" + "WildAmbientCrab.cpp" + "WildAndScared.cpp" + "WildGfGlowbug.cpp" + "WildNinjaBricks.cpp" + "WildNinjaStudent.cpp" + "WildNinjaSensei.cpp" + "WildPants.cpp" PARENT_SCOPE) diff --git a/dScripts/ai/WILD/WildAmbientCrab.cpp b/dScripts/ai/WILD/WildAmbientCrab.cpp new file mode 100644 index 00000000..7b5b3d45 --- /dev/null +++ b/dScripts/ai/WILD/WildAmbientCrab.cpp @@ -0,0 +1,27 @@ +#include "WildAmbientCrab.h" +#include "GameMessages.h" + +void WildAmbientCrab::OnStartup(Entity* self){ + self->SetVar(u"flipped", true); + GameMessages::SendPlayAnimation(self, u"idle"); +} + +void WildAmbientCrab::OnUse(Entity* self, Entity* user) { + auto flipped = self->GetVar(u"flipped"); + if (flipped) { + self->AddTimer("Flipping", 0.6f); + GameMessages::SendPlayAnimation(self, u"flip-over"); + self->SetVar(u"flipped", false); + } else if (!flipped) { + self->AddTimer("Flipback", 0.8f); + GameMessages::SendPlayAnimation(self, u"flip-back"); + self->SetVar(u"flipped", true); + } +} + +void WildAmbientCrab::OnTimerDone(Entity* self, std::string timerName) { + if (timerName == "Flipping") GameMessages::SendPlayAnimation(self, u"over-idle"); + else if (timerName == "Flipback") GameMessages::SendPlayAnimation(self, u"idle"); +} + + diff --git a/dScripts/ai/WILD/WildAmbientCrab.h b/dScripts/ai/WILD/WildAmbientCrab.h new file mode 100644 index 00000000..0e1b3877 --- /dev/null +++ b/dScripts/ai/WILD/WildAmbientCrab.h @@ -0,0 +1,9 @@ +#pragma once +#include "CppScripts.h" + +class WildAmbientCrab final : public CppScripts::Script { +public: + void OnStartup(Entity* self) override; + void OnTimerDone(Entity* self, std::string timerName) override; + void OnUse(Entity* self, Entity* user) override; +}; diff --git a/dScripts/ai/WILD/WildAndScared.cpp b/dScripts/ai/WILD/WildAndScared.cpp new file mode 100644 index 00000000..d2e89c40 --- /dev/null +++ b/dScripts/ai/WILD/WildAndScared.cpp @@ -0,0 +1,6 @@ +#include "WildAndScared.h" +#include "GameMessages.h" + +void WildAndScared::OnUse(Entity* self, Entity* user) { + GameMessages::SendPlayAnimation(self, u"scared"); +} diff --git a/dScripts/ai/WILD/WildAndScared.h b/dScripts/ai/WILD/WildAndScared.h new file mode 100644 index 00000000..c94fb06d --- /dev/null +++ b/dScripts/ai/WILD/WildAndScared.h @@ -0,0 +1,7 @@ +#pragma once +#include "CppScripts.h" + +class WildAndScared : public CppScripts::Script { +public: + void OnUse(Entity* self, Entity* user) override; +}; diff --git a/dScripts/ai/WILD/WildGfGlowbug.cpp b/dScripts/ai/WILD/WildGfGlowbug.cpp new file mode 100644 index 00000000..d834f5b5 --- /dev/null +++ b/dScripts/ai/WILD/WildGfGlowbug.cpp @@ -0,0 +1,28 @@ +#include "WildGfGlowbug.h" +#include "GameMessages.h" + +void WildGfGlowbug::OnStartup(Entity* self){ + self->SetVar(u"switch", false); +} + +void WildGfGlowbug::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2, int32_t param3) { + if (args == "physicsReady") { + auto switchState = self->GetVar(u"switch"); + if (!switchState) { + GameMessages::SendStopFXEffect(self, true, "glowlight"); + } else if (switchState) { + GameMessages::SendPlayFXEffect(self, -1, u"light", "glowlight", LWOOBJID_EMPTY); + } + } +} + +void WildGfGlowbug::OnUse(Entity* self, Entity* user) { + auto switchState = self->GetVar(u"switch"); + if (switchState) { + GameMessages::SendStopFXEffect(self, true, "glowlight"); + self->SetVar(u"switch", false); + } else if (!switchState) { + GameMessages::SendPlayFXEffect(self, -1, u"light", "glowlight", LWOOBJID_EMPTY); + self->SetVar(u"switch", true); + } +} diff --git a/dScripts/ai/WILD/WildGfGlowbug.h b/dScripts/ai/WILD/WildGfGlowbug.h new file mode 100644 index 00000000..03242372 --- /dev/null +++ b/dScripts/ai/WILD/WildGfGlowbug.h @@ -0,0 +1,9 @@ +#pragma once +#include "CppScripts.h" + +class WildGfGlowbug : public CppScripts::Script { +public: + void OnStartup(Entity* self) override; + void OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2, int32_t param3) override; + void OnUse(Entity* self, Entity* user) override; +}; diff --git a/dScripts/ai/WILD/WildNinjaBricks.cpp b/dScripts/ai/WILD/WildNinjaBricks.cpp new file mode 100644 index 00000000..4fa65b01 --- /dev/null +++ b/dScripts/ai/WILD/WildNinjaBricks.cpp @@ -0,0 +1,13 @@ +#include "WildNinjaBricks.h" +#include "Entity.h" + +void WildNinjaBricks::OnStartup(Entity* self) { + self->AddToGroup("Ninjastuff"); +} + +void WildNinjaBricks::OnNotifyObject(Entity* self, Entity* sender, const std::string& name, int32_t param1, int32_t param2) { + if (name == "Crane") GameMessages::SendPlayAnimation(self, u"crane"); + else if (name == "Tiger") GameMessages::SendPlayAnimation(self, u"tiger"); + else if (name == "Mantis") GameMessages::SendPlayAnimation(self, u"mantis"); +} + diff --git a/dScripts/ai/WILD/WildNinjaBricks.h b/dScripts/ai/WILD/WildNinjaBricks.h new file mode 100644 index 00000000..9578e37a --- /dev/null +++ b/dScripts/ai/WILD/WildNinjaBricks.h @@ -0,0 +1,9 @@ +#pragma once +#include "CppScripts.h" + +class WildNinjaBricks : public CppScripts::Script { +public: + void OnStartup(Entity* self) override; + void OnNotifyObject(Entity* self, Entity* sender, const std::string& name, int32_t param1 = 0, int32_t param2 = 0) override; +}; + diff --git a/dScripts/ai/WILD/WildNinjaSensei.cpp b/dScripts/ai/WILD/WildNinjaSensei.cpp new file mode 100644 index 00000000..42ddfa21 --- /dev/null +++ b/dScripts/ai/WILD/WildNinjaSensei.cpp @@ -0,0 +1,36 @@ +#include "WildNinjaSensei.h" +#include "Entity.h" + +void WildNinjaSensei::OnStartup(Entity* self) { + GameMessages::SendPlayAnimation(self, u"bow"); + self->AddTimer("CraneStart", 5); +} + +void WildNinjaSensei::OnTimerDone(Entity* self, std::string timerName) { + if (timerName == "CraneStart") { + auto ninjas = EntityManager::Instance()->GetEntitiesInGroup("Ninjastuff"); + for (auto ninja : ninjas) ninja->NotifyObject(self, "Crane"); + self->AddTimer("Bow", 15.5f); + self->AddTimer("TigerStart", 25); + GameMessages::SendPlayAnimation(self, u"crane"); + } else if (timerName == "TigerStart") { + auto ninjas = EntityManager::Instance()->GetEntitiesInGroup("Ninjastuff"); + GameMessages::SendPlayAnimation(self, u"bow"); + for (auto ninja : ninjas) ninja->NotifyObject(self, "Tiger"); + self->AddTimer("Bow", 15.5f); + self->AddTimer("MantisStart", 25); + GameMessages::SendPlayAnimation(self, u"tiger"); + } else if (timerName == "MantisStart") { + auto ninjas = EntityManager::Instance()->GetEntitiesInGroup("Ninjastuff"); + GameMessages::SendPlayAnimation(self, u"tiger"); + for (auto ninja : ninjas) ninja->NotifyObject(self, "Mantis"); + self->AddTimer("Bow", 15.5f); + self->AddTimer("CraneStart", 25); + GameMessages::SendPlayAnimation(self, u"mantis"); + } else if (timerName == "Bow") { + auto ninjas = EntityManager::Instance()->GetEntitiesInGroup("Ninjastuff"); + for (auto ninja : ninjas) ninja->NotifyObject(self, "Bow"); + GameMessages::SendPlayAnimation(self, u"bow"); + } +} + diff --git a/dScripts/ai/WILD/WildNinjaSensei.h b/dScripts/ai/WILD/WildNinjaSensei.h new file mode 100644 index 00000000..c14b6f08 --- /dev/null +++ b/dScripts/ai/WILD/WildNinjaSensei.h @@ -0,0 +1,9 @@ +#pragma once +#include "CppScripts.h" + +class WildNinjaSensei : public CppScripts::Script { +public: + void OnStartup(Entity* self); + void OnTimerDone(Entity* self, std::string timerName); +}; + diff --git a/dScripts/ai/WILD/WildNinjaStudent.cpp b/dScripts/ai/WILD/WildNinjaStudent.cpp new file mode 100644 index 00000000..b7e2f585 --- /dev/null +++ b/dScripts/ai/WILD/WildNinjaStudent.cpp @@ -0,0 +1,14 @@ +#include "WildNinjaStudent.h" +#include "GameMessages.h" + +void WildNinjaStudent::OnStartup(Entity* self) { + self->AddToGroup("Ninjastuff"); + GameMessages::SendPlayAnimation(self, u"bow"); +} + +void WildNinjaStudent::OnNotifyObject(Entity* self, Entity* sender, const std::string& name, int32_t param1, int32_t param2) { + if (name == "Crane") GameMessages::SendPlayAnimation(self, u"crane"); + else if (name == "Tiger") GameMessages::SendPlayAnimation(self, u"tiger"); + else if (name == "Mantis") GameMessages::SendPlayAnimation(self, u"mantis"); + else if (name == "Bow") GameMessages::SendPlayAnimation(self, u"bow"); +} diff --git a/dScripts/ai/WILD/WildNinjaStudent.h b/dScripts/ai/WILD/WildNinjaStudent.h new file mode 100644 index 00000000..b76e5fa5 --- /dev/null +++ b/dScripts/ai/WILD/WildNinjaStudent.h @@ -0,0 +1,9 @@ +#pragma once +#include "CppScripts.h" + +class WildNinjaStudent : public CppScripts::Script { +public: + void OnStartup(Entity* self) override; + void OnNotifyObject(Entity* self, Entity* sender, const std::string& name, int32_t param1 = 0, int32_t param2 = 0) override; +}; + diff --git a/dScripts/ai/WILD/WildPants.cpp b/dScripts/ai/WILD/WildPants.cpp new file mode 100644 index 00000000..7c5e1cd2 --- /dev/null +++ b/dScripts/ai/WILD/WildPants.cpp @@ -0,0 +1,10 @@ +#include "WildPants.h" +#include "GameMessages.h" + +void WildPants::OnStartup(Entity* self) { + self->SetProximityRadius(5, "scardyPants"); +} + +void WildPants::OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) { + if (status == "ENTER") GameMessages::SendPlayAnimation(self, u"scared"); +} diff --git a/dScripts/ai/SPEC/SpecialImaginePowerupSpawner.h b/dScripts/ai/WILD/WildPants.h similarity index 73% rename from dScripts/ai/SPEC/SpecialImaginePowerupSpawner.h rename to dScripts/ai/WILD/WildPants.h index eb628951..c6968045 100644 --- a/dScripts/ai/SPEC/SpecialImaginePowerupSpawner.h +++ b/dScripts/ai/WILD/WildPants.h @@ -1,7 +1,7 @@ #pragma once #include "CppScripts.h" -class SpecialImaginePowerupSpawner final : public CppScripts::Script +class WildPants : public CppScripts::Script { public: void OnStartup(Entity* self) override; diff --git a/dScripts/client/ai/PR/CrabServer.cpp b/dScripts/client/ai/PR/CrabServer.cpp index 890b8ed9..f30142ba 100644 --- a/dScripts/client/ai/PR/CrabServer.cpp +++ b/dScripts/client/ai/PR/CrabServer.cpp @@ -1,5 +1,6 @@ #include "CrabServer.h" #include "PetComponent.h" +#include "ePetTamingNotifyType.h" void CrabServer::OnStartup(Entity* self) { auto* petComponent = self->GetComponent(); @@ -23,16 +24,16 @@ void CrabServer::OnTimerDone(Entity* self, std::string timerName) { if (petComponent == nullptr || petComponent->GetOwner() != nullptr) return; - self->Smash(self->GetObjectID(), SILENT); + self->Smash(self->GetObjectID(), eKillType::SILENT); } } -void CrabServer::OnNotifyPetTamingMinigame(Entity* self, Entity* tamer, eNotifyType type) { - if (type == NOTIFY_TYPE_BEGIN) { +void CrabServer::OnNotifyPetTamingMinigame(Entity* self, Entity* tamer, ePetTamingNotifyType type) { + if (type == ePetTamingNotifyType::BEGIN) { self->CancelTimer("killself"); - } else if (type == NOTIFY_TYPE_QUIT || type == NOTIFY_TYPE_FAILED) { - self->Smash(self->GetObjectID(), SILENT); - } else if (type == NOTIFY_TYPE_SUCCESS) { + } else if (type == ePetTamingNotifyType::QUIT || type == ePetTamingNotifyType::FAILED) { + self->Smash(self->GetObjectID(), eKillType::SILENT); + } else if (type == ePetTamingNotifyType::SUCCESS) { auto* petComponent = self->GetComponent(); if (petComponent == nullptr) return; diff --git a/dScripts/client/ai/PR/CrabServer.h b/dScripts/client/ai/PR/CrabServer.h index 28533cb5..8c689dbd 100644 --- a/dScripts/client/ai/PR/CrabServer.h +++ b/dScripts/client/ai/PR/CrabServer.h @@ -6,5 +6,5 @@ class CrabServer : public CppScripts::Script public: void OnStartup(Entity* self) override; void OnTimerDone(Entity* self, std::string timerName) override; - void OnNotifyPetTamingMinigame(Entity* self, Entity* tamer, eNotifyType type) override; + void OnNotifyPetTamingMinigame(Entity* self, Entity* tamer, ePetTamingNotifyType type) override; }; diff --git a/dScripts/zone/PROPERTY/FV/ZoneFvProperty.cpp b/dScripts/zone/PROPERTY/FV/ZoneFvProperty.cpp index 67ada039..8b8072ad 100644 --- a/dScripts/zone/PROPERTY/FV/ZoneFvProperty.cpp +++ b/dScripts/zone/PROPERTY/FV/ZoneFvProperty.cpp @@ -29,8 +29,8 @@ void ZoneFvProperty::SetGameVariables(Entity* self) { self->SetVar>(AmbientFXSpawner, { "Ash", "FX", "Fog" }); self->SetVar>(BehaviorObjsSpawner, {}); - self->SetVar(defeatedProperyFlag, 99); - self->SetVar(placedModelFlag, 107); + self->SetVar(defeatedProperyFlag, 99); + self->SetVar(placedModelFlag, 107); self->SetVar(guardMissionFlag, 874); self->SetVar(brickLinkMissionIDFlag, 950); self->SetVar(passwordFlag, "s3kratK1ttN"); diff --git a/dScripts/zone/PROPERTY/GF/ZoneGfProperty.cpp b/dScripts/zone/PROPERTY/GF/ZoneGfProperty.cpp index 565d8cd6..87b2345d 100644 --- a/dScripts/zone/PROPERTY/GF/ZoneGfProperty.cpp +++ b/dScripts/zone/PROPERTY/GF/ZoneGfProperty.cpp @@ -29,8 +29,8 @@ void ZoneGfProperty::SetGameVariables(Entity* self) { self->SetVar>(AmbientFXSpawner, { "Birds", "Falls", "Sunbeam" }); self->SetVar>(BehaviorObjsSpawner, { "TrappedPlatform", "IceBarrier", "FireBeast" }); - self->SetVar(defeatedProperyFlag, 98); - self->SetVar(placedModelFlag, 106); + self->SetVar(defeatedProperyFlag, 98); + self->SetVar(placedModelFlag, 106); self->SetVar(guardMissionFlag, 873); self->SetVar(brickLinkMissionIDFlag, 949); self->SetVar(passwordFlag, "s3kratK1ttN"); diff --git a/dScripts/zone/PROPERTY/NS/ZoneNsProperty.cpp b/dScripts/zone/PROPERTY/NS/ZoneNsProperty.cpp index 49364ee8..52bb02e2 100644 --- a/dScripts/zone/PROPERTY/NS/ZoneNsProperty.cpp +++ b/dScripts/zone/PROPERTY/NS/ZoneNsProperty.cpp @@ -30,8 +30,8 @@ void ZoneNsProperty::SetGameVariables(Entity* self) { self->SetVar>(AmbientFXSpawner, { "Rockets" }); self->SetVar>(BehaviorObjsSpawner, { "Cage", "Platform", "Door" }); - self->SetVar(defeatedProperyFlag, 97); - self->SetVar(placedModelFlag, 105); + self->SetVar(defeatedProperyFlag, 97); + self->SetVar(placedModelFlag, 105); self->SetVar(guardMissionFlag, 872); self->SetVar(brickLinkMissionIDFlag, 948); self->SetVar(passwordFlag, "s3kratK1ttN"); diff --git a/dWorldServer/WorldServer.cpp b/dWorldServer/WorldServer.cpp index 8a603878..18625960 100644 --- a/dWorldServer/WorldServer.cpp +++ b/dWorldServer/WorldServer.cpp @@ -31,7 +31,6 @@ #include "PacketUtils.h" #include "WorldPackets.h" #include "UserManager.h" -#include "dMessageIdentifiers.h" #include "CDClientManager.h" #include "CDClientDatabase.h" #include "GeneralUtils.h" @@ -61,10 +60,16 @@ #include "AssetManager.h" #include "LevelProgressionComponent.h" #include "eBlueprintSaveResponseType.h" -#include "AMFFormat.h" +#include "Amf3.h" #include "NiPoint3.h" #include "eServerDisconnectIdentifiers.h" - +#include "eObjectBits.h" +#include "eConnectionType.h" +#include "eServerMessageType.h" +#include "eChatInternalMessageType.h" +#include "eWorldMessageType.h" +#include "eMasterMessageType.h" +#include "eGameMessageType.h" #include "ZCompression.h" namespace Game { @@ -546,13 +551,12 @@ void HandlePacketChat(Packet* packet) { } if (packet->data[0] == ID_USER_PACKET_ENUM) { - if (packet->data[1] == CHAT_INTERNAL) { - switch (packet->data[3]) { - case MSG_CHAT_INTERNAL_ROUTE_TO_PLAYER: { - CINSTREAM; + if (static_cast(packet->data[1]) == eConnectionType::CHAT_INTERNAL) { + switch (static_cast(packet->data[3])) { + case eChatInternalMessageType::ROUTE_TO_PLAYER: { + CINSTREAM_SKIP_HEADER; LWOOBJID playerID; inStream.Read(playerID); - inStream.Read(playerID); auto player = EntityManager::Instance()->GetEntity(playerID); if (!player) return; @@ -570,10 +574,8 @@ void HandlePacketChat(Packet* packet) { break; } - case MSG_CHAT_INTERNAL_ANNOUNCEMENT: { - CINSTREAM; - LWOOBJID header; - inStream.Read(header); + case eChatInternalMessageType::ANNOUNCEMENT: { + CINSTREAM_SKIP_HEADER; std::string title; std::string msg; @@ -596,25 +598,20 @@ void HandlePacketChat(Packet* packet) { //Send to our clients: AMFArrayValue args; - auto* titleValue = new AMFStringValue(); - titleValue->SetStringValue(title.c_str()); - auto* messageValue = new AMFStringValue(); - messageValue->SetStringValue(msg.c_str()); - args.InsertValue("title", titleValue); - args.InsertValue("message", messageValue); + args.Insert("title", title); + args.Insert("message", msg); - GameMessages::SendUIMessageServerToAllClients("ToggleAnnounce", &args); + GameMessages::SendUIMessageServerToAllClients("ToggleAnnounce", args); break; } - case MSG_CHAT_INTERNAL_MUTE_UPDATE: { - CINSTREAM; + case eChatInternalMessageType::MUTE_UPDATE: { + CINSTREAM_SKIP_HEADER; LWOOBJID playerId; time_t expire = 0; inStream.Read(playerId); - inStream.Read(playerId); inStream.Read(expire); auto* entity = EntityManager::Instance()->GetEntity(playerId); @@ -628,10 +625,8 @@ void HandlePacketChat(Packet* packet) { break; } - case MSG_CHAT_INTERNAL_TEAM_UPDATE: { - CINSTREAM; - LWOOBJID header; - inStream.Read(header); + case eChatInternalMessageType::TEAM_UPDATE: { + CINSTREAM_SKIP_HEADER; LWOOBJID teamID = 0; char lootOption = 0; @@ -705,7 +700,7 @@ void HandlePacket(Packet* packet) { { CBITSTREAM; - PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_PLAYER_REMOVED_NOTIFICATION); + PacketUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::PLAYER_REMOVED_NOTIFICATION); bitStream.Write(user->GetLoggedInChar()); Game::chatServer->Send(&bitStream, SYSTEM_PRIORITY, RELIABLE, 0, Game::chatSysAddr, false); } @@ -717,35 +712,35 @@ void HandlePacket(Packet* packet) { } CBITSTREAM; - PacketUtils::WriteHeader(bitStream, MASTER, MSG_MASTER_PLAYER_REMOVED); + PacketUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::PLAYER_REMOVED); bitStream.Write((LWOMAPID)Game::server->GetZoneID()); bitStream.Write((LWOINSTANCEID)instanceID); Game::server->SendToMaster(&bitStream); } - if (packet->data[0] != ID_USER_PACKET_ENUM) return; - if (packet->data[1] == SERVER) { - if (packet->data[3] == MSG_SERVER_VERSION_CONFIRM) { + if (packet->data[0] != ID_USER_PACKET_ENUM || packet->length < 4) return; + if (static_cast(packet->data[1]) == eConnectionType::SERVER) { + if (static_cast(packet->data[3]) == eServerMessageType::VERSION_CONFIRM) { AuthPackets::HandleHandshake(Game::server, packet); } } - if (packet->data[1] == MASTER) { - switch (packet->data[3]) { - case MSG_MASTER_REQUEST_PERSISTENT_ID_RESPONSE: { + if (static_cast(packet->data[1]) == eConnectionType::MASTER) { + switch (static_cast(packet->data[3])) { + case eMasterMessageType::REQUEST_PERSISTENT_ID_RESPONSE: { uint64_t requestID = PacketUtils::ReadPacketU64(8, packet); uint32_t objectID = PacketUtils::ReadPacketU32(16, packet); ObjectIDManager::Instance()->HandleRequestPersistentIDResponse(requestID, objectID); break; } - case MSG_MASTER_REQUEST_ZONE_TRANSFER_RESPONSE: { + case eMasterMessageType::REQUEST_ZONE_TRANSFER_RESPONSE: { uint64_t requestID = PacketUtils::ReadPacketU64(8, packet); ZoneInstanceManager::Instance()->HandleRequestZoneTransferResponse(requestID, packet); break; } - case MSG_MASTER_SESSION_KEY_RESPONSE: { + case eMasterMessageType::SESSION_KEY_RESPONSE: { //Read our session key and to which user it belongs: RakNet::BitStream inStream(packet->data, packet->length, false); uint64_t header = inStream.Read(header); @@ -802,7 +797,7 @@ void HandlePacket(Packet* packet) { //Notify master: { CBITSTREAM; - PacketUtils::WriteHeader(bitStream, MASTER, MSG_MASTER_PLAYER_ADDED); + PacketUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::PLAYER_ADDED); bitStream.Write((LWOMAPID)Game::server->GetZoneID()); bitStream.Write((LWOINSTANCEID)instanceID); Game::server->SendToMaster(&bitStream); @@ -811,27 +806,27 @@ void HandlePacket(Packet* packet) { break; } - case MSG_MASTER_AFFIRM_TRANSFER_REQUEST: { + case eMasterMessageType::AFFIRM_TRANSFER_REQUEST: { const uint64_t requestID = PacketUtils::ReadPacketU64(8, packet); Game::logger->Log("MasterServer", "Got affirmation request of transfer %llu", requestID); CBITSTREAM; - PacketUtils::WriteHeader(bitStream, MASTER, MSG_MASTER_AFFIRM_TRANSFER_RESPONSE); + PacketUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::AFFIRM_TRANSFER_RESPONSE); bitStream.Write(requestID); Game::server->SendToMaster(&bitStream); break; } - case MSG_MASTER_SHUTDOWN: { + case eMasterMessageType::SHUTDOWN: { Game::shouldShutdown = true; Game::logger->Log("WorldServer", "Got shutdown request from master, zone (%i), instance (%i)", Game::server->GetZoneID(), Game::server->GetInstanceID()); break; } - case MSG_MASTER_NEW_SESSION_ALERT: { + case eMasterMessageType::NEW_SESSION_ALERT: { RakNet::BitStream inStream(packet->data, packet->length, false); uint64_t header = inStream.Read(header); uint32_t sessionKey = inStream.Read(sessionKey); @@ -869,10 +864,10 @@ void HandlePacket(Packet* packet) { return; } - if (packet->data[1] != WORLD) return; + if (static_cast(packet->data[1]) != eConnectionType::WORLD) return; - switch (packet->data[3]) { - case MSG_WORLD_CLIENT_VALIDATION: { + switch (static_cast(packet->data[3])) { + case eWorldMessageType::VALIDATION: { std::string username = PacketUtils::ReadString(0x08, packet, true); std::string sessionKey = PacketUtils::ReadString(74, packet, true); std::string clientDatabaseChecksum = PacketUtils::ReadString(packet->length - 33, packet, false); @@ -904,7 +899,7 @@ void HandlePacket(Packet* packet) { //Request the session info from Master: CBITSTREAM; - PacketUtils::WriteHeader(bitStream, MASTER, MSG_MASTER_REQUEST_SESSION_KEY); + PacketUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::REQUEST_SESSION_KEY); PacketUtils::WriteString(bitStream, username, 64); Game::server->SendToMaster(&bitStream); @@ -917,7 +912,7 @@ void HandlePacket(Packet* packet) { break; } - case MSG_WORLD_CLIENT_CHARACTER_LIST_REQUEST: { + case eWorldMessageType::CHARACTER_LIST_REQUEST: { //We need to delete the entity first, otherwise the char list could delete it while it exists in the world! if (Game::server->GetZoneID() != 0) { auto user = UserManager::Instance()->GetUser(packet->systemAddress); @@ -939,12 +934,12 @@ void HandlePacket(Packet* packet) { break; } - case MSG_WORLD_CLIENT_GAME_MSG: { + case eWorldMessageType::GAME_MSG: { RakNet::BitStream bitStream(packet->data, packet->length, false); uint64_t header; LWOOBJID objectID; - uint16_t messageID; + eGameMessageType messageID; bitStream.Read(header); bitStream.Read(objectID); @@ -953,23 +948,23 @@ void HandlePacket(Packet* packet) { RakNet::BitStream dataStream; bitStream.Read(dataStream, bitStream.GetNumberOfUnreadBits()); - GameMessageHandler::HandleMessage(&dataStream, packet->systemAddress, objectID, GAME_MSG(messageID)); + GameMessageHandler::HandleMessage(&dataStream, packet->systemAddress, objectID, messageID); break; } - case MSG_WORLD_CLIENT_CHARACTER_CREATE_REQUEST: { + case eWorldMessageType::CHARACTER_CREATE_REQUEST: { UserManager::Instance()->CreateCharacter(packet->systemAddress, packet); break; } - case MSG_WORLD_CLIENT_LOGIN_REQUEST: { + case eWorldMessageType::LOGIN_REQUEST: { RakNet::BitStream inStream(packet->data, packet->length, false); uint64_t header = inStream.Read(header); LWOOBJID playerID = 0; inStream.Read(playerID); - playerID = GeneralUtils::ClearBit(playerID, OBJECT_BIT_CHARACTER); - playerID = GeneralUtils::ClearBit(playerID, OBJECT_BIT_PERSISTENT); + GeneralUtils::ClearBit(playerID, eObjectBits::CHARACTER); + GeneralUtils::ClearBit(playerID, eObjectBits::PERSISTENT); auto user = UserManager::Instance()->GetUser(packet->systemAddress); @@ -978,7 +973,7 @@ void HandlePacket(Packet* packet) { // This means we swapped characters and we need to remove the previous player from the container. if (static_cast(lastCharacter) != playerID) { CBITSTREAM; - PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_PLAYER_REMOVED_NOTIFICATION); + PacketUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::PLAYER_REMOVED_NOTIFICATION); bitStream.Write(lastCharacter); Game::chatServer->Send(&bitStream, SYSTEM_PRIORITY, RELIABLE, 0, Game::chatSysAddr, false); } @@ -988,18 +983,18 @@ void HandlePacket(Packet* packet) { break; } - case MSG_WORLD_CLIENT_CHARACTER_DELETE_REQUEST: { + case eWorldMessageType::CHARACTER_DELETE_REQUEST: { UserManager::Instance()->DeleteCharacter(packet->systemAddress, packet); UserManager::Instance()->RequestCharacterList(packet->systemAddress); break; } - case MSG_WORLD_CLIENT_CHARACTER_RENAME_REQUEST: { + case eWorldMessageType::CHARACTER_RENAME_REQUEST: { UserManager::Instance()->RenameCharacter(packet->systemAddress, packet); break; } - case MSG_WORLD_CLIENT_LEVEL_LOAD_COMPLETE: { + case eWorldMessageType::LEVEL_LOAD_COMPLETE: { Game::logger->Log("WorldServer", "Received level load complete from user."); User* user = UserManager::Instance()->GetUser(packet->systemAddress); if (user) { @@ -1123,11 +1118,11 @@ void HandlePacket(Packet* packet) { //Send message: { LWOOBJID blueprintID = res->getUInt(1); - blueprintID = GeneralUtils::SetBit(blueprintID, OBJECT_BIT_CHARACTER); - blueprintID = GeneralUtils::SetBit(blueprintID, OBJECT_BIT_PERSISTENT); + GeneralUtils::SetBit(blueprintID, eObjectBits::CHARACTER); + GeneralUtils::SetBit(blueprintID, eObjectBits::PERSISTENT); CBITSTREAM; - PacketUtils::WriteHeader(bitStream, CLIENT, MSG_CLIENT_BLUEPRINT_SAVE_RESPONSE); + PacketUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::BLUEPRINT_SAVE_RESPONSE); bitStream.Write(LWOOBJID_EMPTY); //always zero so that a check on the client passes bitStream.Write(eBlueprintSaveResponseType::EverythingWorked); bitStream.Write(1); @@ -1168,7 +1163,7 @@ void HandlePacket(Packet* packet) { //RakNet::RakString playerName(player->GetCharacter()->GetName().c_str()); CBITSTREAM; - PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_PLAYER_ADDED_NOTIFICATION); + PacketUtils::WriteHeader(bitStream, eConnectionType::CHAT_INTERNAL, eChatInternalMessageType::PLAYER_ADDED_NOTIFICATION); bitStream.Write(player->GetObjectID()); bitStream.Write(playerName.size()); for (size_t i = 0; i < playerName.size(); i++) { @@ -1193,12 +1188,12 @@ void HandlePacket(Packet* packet) { break; } - case MSG_WORLD_CLIENT_POSITION_UPDATE: { + case eWorldMessageType::POSITION_UPDATE: { ClientPackets::HandleClientPositionUpdate(packet->systemAddress, packet); break; } - case MSG_WORLD_CLIENT_MAIL: { + case eWorldMessageType::MAIL: { RakNet::BitStream bitStream(packet->data, packet->length, false); LWOOBJID space; bitStream.Read(space); @@ -1206,12 +1201,10 @@ void HandlePacket(Packet* packet) { break; } - case MSG_WORLD_CLIENT_ROUTE_PACKET: { + case eWorldMessageType::ROUTE_PACKET: { //Yeet to chat - CINSTREAM; - uint64_t header = 0; + CINSTREAM_SKIP_HEADER; uint32_t size = 0; - inStream.Read(header); inStream.Read(size); if (size > 20000) { @@ -1221,7 +1214,7 @@ void HandlePacket(Packet* packet) { CBITSTREAM; - PacketUtils::WriteHeader(bitStream, CHAT, packet->data[14]); + PacketUtils::WriteHeader(bitStream, eConnectionType::CHAT, packet->data[14]); //We need to insert the player's objectID so the chat server can find who originated this request: LWOOBJID objectID = 0; @@ -1242,12 +1235,12 @@ void HandlePacket(Packet* packet) { break; } - case MSG_WORLD_CLIENT_STRING_CHECK: { + case eWorldMessageType::STRING_CHECK: { ClientPackets::HandleChatModerationRequest(packet->systemAddress, packet); break; } - case MSG_WORLD_CLIENT_GENERAL_CHAT_MESSAGE: { + case eWorldMessageType::GENERAL_CHAT_MESSAGE: { if (chatDisabled) { ChatPackets::SendMessageFail(packet->systemAddress); } else { @@ -1257,7 +1250,7 @@ void HandlePacket(Packet* packet) { break; } - case MSG_WORLD_CLIENT_HANDLE_FUNNESS: { + case eWorldMessageType::HANDLE_FUNNESS: { //This means the client is running slower or faster than it should. //Could be insane lag, but I'mma just YEET them as it's usually speedhacking. //This is updated to now count the amount of times we've been caught "speedhacking" to kick with a delay @@ -1345,6 +1338,6 @@ void FinalizeShutdown() { void SendShutdownMessageToMaster() { CBITSTREAM; - PacketUtils::WriteHeader(bitStream, MASTER, MSG_MASTER_SHUTDOWN_RESPONSE); + PacketUtils::WriteHeader(bitStream, eConnectionType::MASTER, eMasterMessageType::SHUTDOWN_RESPONSE); Game::server->SendToMaster(&bitStream); } diff --git a/dZoneManager/dZoneManager.cpp b/dZoneManager/dZoneManager.cpp index ac3a7008..a26e912f 100644 --- a/dZoneManager/dZoneManager.cpp +++ b/dZoneManager/dZoneManager.cpp @@ -11,6 +11,9 @@ #include "WorldConfig.h" #include "CDZoneTableTable.h" #include +#include "eObjectBits.h" +#include "CDZoneTableTable.h" +#include "AssetManager.h" #include "../dWorldServer/ObjectIDManager.h" @@ -133,8 +136,7 @@ LWOOBJID dZoneManager::MakeSpawner(SpawnerInfo info) { if (objectId == LWOOBJID_EMPTY) { objectId = ObjectIDManager::Instance()->GenerateObjectID(); - - objectId = GeneralUtils::SetBit(objectId, OBJECT_BIT_CLIENT); + GeneralUtils::SetBit(objectId, eObjectBits::CLIENT); info.spawnerID = objectId; } @@ -227,6 +229,17 @@ uint32_t dZoneManager::GetUniqueMissionIdStartingValue() { return m_UniqueMissionIdStart; } +bool dZoneManager::CheckIfAccessibleZone(LWOMAPID zoneID) { + //We're gonna go ahead and presume we've got the db loaded already: + CDZoneTableTable* zoneTable = CDClientManager::Instance().GetTable(); + const CDZoneTable* zone = zoneTable->Query(zoneID); + if (zone != nullptr) { + return Game::assetManager->HasFile(("maps/" + zone->zoneName).c_str()); + } else { + return false; + } +} + void dZoneManager::LoadWorldConfig() { Game::logger->Log("dZoneManager", "Loading WorldConfig into memory"); diff --git a/dZoneManager/dZoneManager.h b/dZoneManager/dZoneManager.h index c1776e79..3086e6d7 100644 --- a/dZoneManager/dZoneManager.h +++ b/dZoneManager/dZoneManager.h @@ -50,6 +50,7 @@ public: Entity* GetZoneControlObject() { return m_ZoneControlObject; } bool GetPlayerLoseCoinOnDeath() { return m_PlayerLoseCoinsOnDeath; } uint32_t GetUniqueMissionIdStartingValue(); + bool CheckIfAccessibleZone(LWOMAPID zoneID); // The world config should not be modified by a caller. const WorldConfig* GetWorldConfig() { diff --git a/migrations/cdserver/6_ninja_sensei.sql b/migrations/cdserver/6_ninja_sensei.sql new file mode 100644 index 00000000..f3828b07 --- /dev/null +++ b/migrations/cdserver/6_ninja_sensei.sql @@ -0,0 +1,2 @@ +INSERT INTO ScriptComponent (id, script_name, client_script_name) VALUES (228, 'scripts\ai\FV\L_ACT_NINJA_SENSEI.lua', null); +UPDATE ComponentsRegistry SET component_id = 228 WHERE id = 2489 AND component_type = 5; diff --git a/tests/dCommonTests/AMFDeserializeTests.cpp b/tests/dCommonTests/AMFDeserializeTests.cpp index 3811a706..5a9d91e6 100644 --- a/tests/dCommonTests/AMFDeserializeTests.cpp +++ b/tests/dCommonTests/AMFDeserializeTests.cpp @@ -3,14 +3,17 @@ #include #include "AMFDeserialize.h" -#include "AMFFormat.h" +#include "Amf3.h" + +#include "Game.h" +#include "dLogger.h" /** * Helper method that all tests use to get their respective AMF. */ -std::unique_ptr ReadFromBitStream(RakNet::BitStream* bitStream) { +AMFBaseValue* ReadFromBitStream(RakNet::BitStream* bitStream) { AMFDeserialize deserializer; - std::unique_ptr returnValue(deserializer.Read(bitStream)); + AMFBaseValue* returnValue(deserializer.Read(bitStream)); return returnValue; } @@ -18,10 +21,10 @@ std::unique_ptr ReadFromBitStream(RakNet::BitStream* bitStream) { * @brief Test reading an AMFUndefined value from a BitStream. */ TEST(dCommonTests, AMFDeserializeAMFUndefinedTest) { - CBITSTREAM + CBITSTREAM; bitStream.Write(0x00); - std::unique_ptr res(ReadFromBitStream(&bitStream)); - ASSERT_EQ(res->GetValueType(), AMFValueType::AMFUndefined); + std::unique_ptr res(ReadFromBitStream(&bitStream)); + ASSERT_EQ(res->GetValueType(), eAmf::Undefined); } /** @@ -29,54 +32,54 @@ TEST(dCommonTests, AMFDeserializeAMFUndefinedTest) { * */ TEST(dCommonTests, AMFDeserializeAMFNullTest) { - CBITSTREAM + CBITSTREAM; bitStream.Write(0x01); - std::unique_ptr res(ReadFromBitStream(&bitStream)); - ASSERT_EQ(res->GetValueType(), AMFValueType::AMFNull); + std::unique_ptr res(ReadFromBitStream(&bitStream)); + ASSERT_EQ(res->GetValueType(), eAmf::Null); } /** * @brief Test reading an AMFFalse value from a BitStream. */ TEST(dCommonTests, AMFDeserializeAMFFalseTest) { - CBITSTREAM + CBITSTREAM; bitStream.Write(0x02); - std::unique_ptr res(ReadFromBitStream(&bitStream)); - ASSERT_EQ(res->GetValueType(), AMFValueType::AMFFalse); + std::unique_ptr res(ReadFromBitStream(&bitStream)); + ASSERT_EQ(res->GetValueType(), eAmf::False); } /** * @brief Test reading an AMFTrue value from a BitStream. */ TEST(dCommonTests, AMFDeserializeAMFTrueTest) { - CBITSTREAM + CBITSTREAM; bitStream.Write(0x03); - std::unique_ptr res(ReadFromBitStream(&bitStream)); - ASSERT_EQ(res->GetValueType(), AMFValueType::AMFTrue); + std::unique_ptr res(ReadFromBitStream(&bitStream)); + ASSERT_EQ(res->GetValueType(), eAmf::True); } /** * @brief Test reading an AMFInteger value from a BitStream. */ TEST(dCommonTests, AMFDeserializeAMFIntegerTest) { - CBITSTREAM + CBITSTREAM; { bitStream.Write(0x04); // 127 == 01111111 bitStream.Write(127); - std::unique_ptr res(ReadFromBitStream(&bitStream)); - ASSERT_EQ(res->GetValueType(), AMFValueType::AMFInteger); + std::unique_ptr res(ReadFromBitStream(&bitStream)); + ASSERT_EQ(res->GetValueType(), eAmf::Integer); // Check that the max value of a byte can be read correctly - ASSERT_EQ(static_cast(res.get())->GetIntegerValue(), 127); + ASSERT_EQ(static_cast(res.get())->GetValue(), 127); } bitStream.Reset(); { bitStream.Write(0x04); bitStream.Write(UINT32_MAX); - std::unique_ptr res(ReadFromBitStream(&bitStream)); - ASSERT_EQ(res->GetValueType(), AMFValueType::AMFInteger); + std::unique_ptr res(ReadFromBitStream(&bitStream)); + ASSERT_EQ(res->GetValueType(), eAmf::Integer); // Check that we can read the maximum value correctly - ASSERT_EQ(static_cast(res.get())->GetIntegerValue(), 536870911); + ASSERT_EQ(static_cast(res.get())->GetValue(), 536870911); } bitStream.Reset(); { @@ -87,10 +90,10 @@ TEST(dCommonTests, AMFDeserializeAMFIntegerTest) { bitStream.Write(255); // 127 == 01111111 bitStream.Write(127); - std::unique_ptr res(ReadFromBitStream(&bitStream)); - ASSERT_EQ(res->GetValueType(), AMFValueType::AMFInteger); + std::unique_ptr res(ReadFromBitStream(&bitStream)); + ASSERT_EQ(res->GetValueType(), eAmf::Integer); // Check that short max can be read correctly - ASSERT_EQ(static_cast(res.get())->GetIntegerValue(), UINT16_MAX); + ASSERT_EQ(static_cast(res.get())->GetValue(), UINT16_MAX); } bitStream.Reset(); { @@ -99,10 +102,10 @@ TEST(dCommonTests, AMFDeserializeAMFIntegerTest) { bitStream.Write(255); // 127 == 01111111 bitStream.Write(127); - std::unique_ptr res(ReadFromBitStream(&bitStream)); - ASSERT_EQ(res->GetValueType(), AMFValueType::AMFInteger); + std::unique_ptr res(ReadFromBitStream(&bitStream)); + ASSERT_EQ(res->GetValueType(), eAmf::Integer); // Check that 2 byte max can be read correctly - ASSERT_EQ(static_cast(res.get())->GetIntegerValue(), 16383); + ASSERT_EQ(static_cast(res.get())->GetValue(), 16383); } } @@ -110,42 +113,42 @@ TEST(dCommonTests, AMFDeserializeAMFIntegerTest) { * @brief Test reading an AMFDouble value from a BitStream. */ TEST(dCommonTests, AMFDeserializeAMFDoubleTest) { - CBITSTREAM + CBITSTREAM; bitStream.Write(0x05); bitStream.Write(25346.4f); - std::unique_ptr res(ReadFromBitStream(&bitStream)); - ASSERT_EQ(res->GetValueType(), AMFValueType::AMFDouble); - ASSERT_EQ(static_cast(res.get())->GetDoubleValue(), 25346.4f); + std::unique_ptr res(ReadFromBitStream(&bitStream)); + ASSERT_EQ(res->GetValueType(), eAmf::Double); + ASSERT_EQ(static_cast(res.get())->GetValue(), 25346.4f); } /** * @brief Test reading an AMFString value from a BitStream. */ TEST(dCommonTests, AMFDeserializeAMFStringTest) { - CBITSTREAM + CBITSTREAM; bitStream.Write(0x06); bitStream.Write(0x0F); std::string toWrite = "stateID"; for (auto e : toWrite) bitStream.Write(e); - std::unique_ptr res(ReadFromBitStream(&bitStream)); - ASSERT_EQ(res->GetValueType(), AMFValueType::AMFString); - ASSERT_EQ(static_cast(res.get())->GetStringValue(), "stateID"); + std::unique_ptr res(ReadFromBitStream(&bitStream)); + ASSERT_EQ(res->GetValueType(), eAmf::String); + ASSERT_EQ(static_cast(res.get())->GetValue(), "stateID"); } /** * @brief Test reading an AMFArray value from a BitStream. */ TEST(dCommonTests, AMFDeserializeAMFArrayTest) { - CBITSTREAM + CBITSTREAM; // Test empty AMFArray bitStream.Write(0x09); bitStream.Write(0x01); bitStream.Write(0x01); { - std::unique_ptr res(ReadFromBitStream(&bitStream)); - ASSERT_EQ(res->GetValueType(), AMFValueType::AMFArray); - ASSERT_EQ(static_cast(res.get())->GetAssociativeMap().size(), 0); - ASSERT_EQ(static_cast(res.get())->GetDenseArray().size(), 0); + std::unique_ptr res(ReadFromBitStream(&bitStream)); + ASSERT_EQ(res->GetValueType(), eAmf::Array); + ASSERT_EQ(static_cast(res.get())->GetAssociative().size(), 0); + ASSERT_EQ(static_cast(res.get())->GetDense().size(), 0); } bitStream.Reset(); // Test a key'd value and dense value @@ -161,33 +164,32 @@ TEST(dCommonTests, AMFDeserializeAMFArrayTest) { bitStream.Write(0x0B); for (auto e : "10447") if (e != '\0') bitStream.Write(e); { - std::unique_ptr res(ReadFromBitStream(&bitStream)); - ASSERT_EQ(res->GetValueType(), AMFValueType::AMFArray); - ASSERT_EQ(static_cast(res.get())->GetAssociativeMap().size(), 1); - ASSERT_EQ(static_cast(res.get())->GetDenseArray().size(), 1); - ASSERT_EQ(static_cast(res.get())->FindValue("BehaviorID")->GetStringValue(), "10447"); - ASSERT_EQ(static_cast(res.get())->GetValueAt(0)->GetStringValue(), "10447"); + std::unique_ptr res(ReadFromBitStream(&bitStream)); + ASSERT_EQ(res->GetValueType(), eAmf::Array); + ASSERT_EQ(static_cast(res.get())->GetAssociative().size(), 1); + ASSERT_EQ(static_cast(res.get())->GetDense().size(), 1); + ASSERT_EQ(static_cast(res.get())->Get("BehaviorID")->GetValue(), "10447"); + ASSERT_EQ(static_cast(res.get())->Get(0)->GetValue(), "10447"); } } /** - * @brief This test checks that if we recieve an unimplemented AMFValueType + * @brief This test checks that if we recieve an unimplemented eAmf * we correctly throw an error and can actch it. - * + * Yes this leaks memory. */ -#pragma message("-- The AMFDeserializeUnimplementedValuesTest causes a known memory leak of 880 bytes since it throws errors! --") TEST(dCommonTests, AMFDeserializeUnimplementedValuesTest) { - std::vector unimplementedValues = { - AMFValueType::AMFXMLDoc, - AMFValueType::AMFDate, - AMFValueType::AMFObject, - AMFValueType::AMFXML, - AMFValueType::AMFByteArray, - AMFValueType::AMFVectorInt, - AMFValueType::AMFVectorUInt, - AMFValueType::AMFVectorDouble, - AMFValueType::AMFVectorObject, - AMFValueType::AMFDictionary + std::vector unimplementedValues = { + eAmf::XMLDoc, + eAmf::Date, + eAmf::Object, + eAmf::XML, + eAmf::ByteArray, + eAmf::VectorInt, + eAmf::VectorUInt, + eAmf::VectorDouble, + eAmf::VectorObject, + eAmf::Dictionary }; // Run unimplemented tests to check that errors are thrown if // unimplemented AMF values are attempted to be parsed. @@ -203,16 +205,16 @@ TEST(dCommonTests, AMFDeserializeUnimplementedValuesTest) { fileStream.close(); - for (auto amfValueType : unimplementedValues) { + for (auto value : unimplementedValues) { RakNet::BitStream testBitStream; for (auto element : baseBitStream) { testBitStream.Write(element); } - testBitStream.Write(amfValueType); + testBitStream.Write(value); bool caughtException = false; try { ReadFromBitStream(&testBitStream); - } catch (AMFValueType unimplementedValueType) { + } catch (eAmf unimplementedValueType) { caughtException = true; } @@ -236,116 +238,116 @@ TEST(dCommonTests, AMFDeserializeLivePacketTest) { testFileStream.close(); - auto resultFromFn = ReadFromBitStream(&testBitStream); + std::unique_ptr resultFromFn(ReadFromBitStream(&testBitStream)); auto result = static_cast(resultFromFn.get()); // Test the outermost array - ASSERT_EQ(result->FindValue("BehaviorID")->GetStringValue(), "10447"); - ASSERT_EQ(result->FindValue("objectID")->GetStringValue(), "288300744895913279"); + ASSERT_EQ(result->Get("BehaviorID")->GetValue(), "10447"); + ASSERT_EQ(result->Get("objectID")->GetValue(), "288300744895913279"); // Test the execution state array - auto executionState = result->FindValue("executionState"); + auto executionState = result->GetArray("executionState"); ASSERT_NE(executionState, nullptr); - auto strips = executionState->FindValue("strips")->GetDenseArray(); + auto strips = executionState->GetArray("strips")->GetDense(); ASSERT_EQ(strips.size(), 1); auto stripsPosition0 = dynamic_cast(strips[0]); - auto actionIndex = stripsPosition0->FindValue("actionIndex"); + auto actionIndex = stripsPosition0->Get("actionIndex"); - ASSERT_EQ(actionIndex->GetDoubleValue(), 0.0f); + ASSERT_EQ(actionIndex->GetValue(), 0.0f); - auto stripIdExecution = stripsPosition0->FindValue("id"); + auto stripIdExecution = stripsPosition0->Get("id"); - ASSERT_EQ(stripIdExecution->GetDoubleValue(), 0.0f); + ASSERT_EQ(stripIdExecution->GetValue(), 0.0f); - auto stateIDExecution = executionState->FindValue("stateID"); + auto stateIdExecution = executionState->Get("stateID"); - ASSERT_EQ(stateIDExecution->GetDoubleValue(), 0.0f); + ASSERT_EQ(stateIdExecution->GetValue(), 0.0f); - auto states = result->FindValue("states")->GetDenseArray(); + auto states = result->GetArray("states")->GetDense(); ASSERT_EQ(states.size(), 1); auto firstState = dynamic_cast(states[0]); - auto stateID = firstState->FindValue("id"); + auto stateID = firstState->Get("id"); - ASSERT_EQ(stateID->GetDoubleValue(), 0.0f); + ASSERT_EQ(stateID->GetValue(), 0.0f); - auto stripsInState = firstState->FindValue("strips")->GetDenseArray(); + auto stripsInState = firstState->GetArray("strips")->GetDense(); ASSERT_EQ(stripsInState.size(), 1); auto firstStrip = dynamic_cast(stripsInState[0]); - auto actionsInFirstStrip = firstStrip->FindValue("actions")->GetDenseArray(); + auto actionsInFirstStrip = firstStrip->GetArray("actions")->GetDense(); ASSERT_EQ(actionsInFirstStrip.size(), 3); - auto actionID = firstStrip->FindValue("id"); + auto actionID = firstStrip->Get("id"); - ASSERT_EQ(actionID->GetDoubleValue(), 0.0f); + ASSERT_EQ(actionID->GetValue(), 0.0f); - auto uiArray = firstStrip->FindValue("ui"); + auto uiArray = firstStrip->GetArray("ui"); - auto xPos = uiArray->FindValue("x"); - auto yPos = uiArray->FindValue("y"); + auto xPos = uiArray->Get("x"); + auto yPos = uiArray->Get("y"); - ASSERT_EQ(xPos->GetDoubleValue(), 103.0f); - ASSERT_EQ(yPos->GetDoubleValue(), 82.0f); + ASSERT_EQ(xPos->GetValue(), 103.0f); + ASSERT_EQ(yPos->GetValue(), 82.0f); - auto stripId = firstStrip->FindValue("id"); + auto stripId = firstStrip->Get("id"); - ASSERT_EQ(stripId->GetDoubleValue(), 0.0f); + ASSERT_EQ(stripId->GetValue(), 0.0f); auto firstAction = dynamic_cast(actionsInFirstStrip[0]); - auto firstType = firstAction->FindValue("Type"); + auto firstType = firstAction->Get("Type"); - ASSERT_EQ(firstType->GetStringValue(), "OnInteract"); + ASSERT_EQ(firstType->GetValue(), "OnInteract"); - auto firstCallback = firstAction->FindValue("__callbackID__"); + auto firstCallback = firstAction->Get("__callbackID__"); - ASSERT_EQ(firstCallback->GetStringValue(), ""); + ASSERT_EQ(firstCallback->GetValue(), ""); auto secondAction = dynamic_cast(actionsInFirstStrip[1]); - auto secondType = secondAction->FindValue("Type"); + auto secondType = secondAction->Get("Type"); - ASSERT_EQ(secondType->GetStringValue(), "FlyUp"); + ASSERT_EQ(secondType->GetValue(), "FlyUp"); - auto secondCallback = secondAction->FindValue("__callbackID__"); + auto secondCallback = secondAction->Get("__callbackID__"); - ASSERT_EQ(secondCallback->GetStringValue(), ""); + ASSERT_EQ(secondCallback->GetValue(), ""); - auto secondDistance = secondAction->FindValue("Distance"); + auto secondDistance = secondAction->Get("Distance"); - ASSERT_EQ(secondDistance->GetDoubleValue(), 25.0f); + ASSERT_EQ(secondDistance->GetValue(), 25.0f); auto thirdAction = dynamic_cast(actionsInFirstStrip[2]); - auto thirdType = thirdAction->FindValue("Type"); + auto thirdType = thirdAction->Get("Type"); - ASSERT_EQ(thirdType->GetStringValue(), "FlyDown"); + ASSERT_EQ(thirdType->GetValue(), "FlyDown"); - auto thirdCallback = thirdAction->FindValue("__callbackID__"); + auto thirdCallback = thirdAction->Get("__callbackID__"); - ASSERT_EQ(thirdCallback->GetStringValue(), ""); + ASSERT_EQ(thirdCallback->GetValue(), ""); - auto thirdDistance = thirdAction->FindValue("Distance"); + auto thirdDistance = thirdAction->Get("Distance"); - ASSERT_EQ(thirdDistance->GetDoubleValue(), 25.0f); + ASSERT_EQ(thirdDistance->GetValue(), 25.0f); } /** * @brief Tests that having no BitStream returns a nullptr. */ TEST(dCommonTests, AMFDeserializeNullTest) { - auto result = ReadFromBitStream(nullptr); + std::unique_ptr result(ReadFromBitStream(nullptr)); ASSERT_EQ(result.get(), nullptr); } @@ -362,25 +364,25 @@ TEST(dCommonTests, AMFBadConversionTest) { testFileStream.close(); - auto resultFromFn = ReadFromBitStream(&testBitStream); + std::unique_ptr resultFromFn(ReadFromBitStream(&testBitStream)); auto result = static_cast(resultFromFn.get()); // Actually a string value. - ASSERT_EQ(result->FindValue("BehaviorID"), nullptr); + ASSERT_EQ(result->Get("BehaviorID"), nullptr); // Does not exist in the associative portion - ASSERT_EQ(result->FindValue("DOES_NOT_EXIST"), nullptr); + ASSERT_EQ(result->Get("DOES_NOT_EXIST"), nullptr); - result->PushBackValue(new AMFTrueValue()); + result->Push(true); // Exists and is correct type - ASSERT_NE(result->GetValueAt(0), nullptr); + ASSERT_NE(result->Get(0), nullptr); // Value exists but is wrong typing - ASSERT_EQ(result->GetValueAt(0), nullptr); + ASSERT_EQ(result->Get(0), nullptr); // Value is out of bounds - ASSERT_EQ(result->GetValueAt(1), nullptr); + ASSERT_EQ(result->Get(1), nullptr); } /** diff --git a/tests/dCommonTests/Amf3Tests.cpp b/tests/dCommonTests/Amf3Tests.cpp new file mode 100644 index 00000000..a51fe4ba --- /dev/null +++ b/tests/dCommonTests/Amf3Tests.cpp @@ -0,0 +1,116 @@ +#include + +#include + +#include "Amf3.h" + +TEST(dCommonTests, AMF3AssociativeArrayTest) { + + AMFArrayValue array; + array.Insert("true", true); + array.Insert("false", false); + + // test associative can insert values + ASSERT_EQ(array.GetAssociative().size(), 2); + ASSERT_EQ(array.Get("true")->GetValueType(), eAmf::True); + ASSERT_EQ(array.Get("false")->GetValueType(), eAmf::False); + + // Test associative can remove values + array.Remove("true"); + ASSERT_EQ(array.GetAssociative().size(), 1); + ASSERT_EQ(array.Get("true"), nullptr); + ASSERT_EQ(array.Get("false")->GetValueType(), eAmf::False); + + array.Remove("false"); + ASSERT_EQ(array.GetAssociative().size(), 0); + ASSERT_EQ(array.Get("true"), nullptr); + ASSERT_EQ(array.Get("false"), nullptr); + + // Test that multiple of the same key respect only the first element of that key + array.Insert("true", true); + array.Insert("true", false); + ASSERT_EQ(array.GetAssociative().size(), 1); + ASSERT_EQ(array.Get("true")->GetValueType(), eAmf::True); + array.Remove("true"); + + // Now test the dense portion + // Get some out of bounds values and cast to incorrect template types + array.Push(true); + array.Push(false); + + ASSERT_EQ(array.GetDense().size(), 2); + ASSERT_EQ(array.Get(0)->GetValueType(), eAmf::True); + ASSERT_EQ(array.Get(0), nullptr); + ASSERT_EQ(array.Get(1)->GetValueType(), eAmf::False); + ASSERT_EQ(array.Get(155), nullptr); + + array.Pop(); + + ASSERT_EQ(array.GetDense().size(), 1); + ASSERT_EQ(array.Get(0)->GetValueType(), eAmf::True); + ASSERT_EQ(array.Get(0), nullptr); + ASSERT_EQ(array.Get(1), nullptr); + + array.Pop(); + + ASSERT_EQ(array.GetDense().size(), 0); + ASSERT_EQ(array.Get(0), nullptr); + ASSERT_EQ(array.Get(0), nullptr); + ASSERT_EQ(array.Get(1), nullptr); +} + +TEST(dCommonTests, AMF3InsertionAssociativeTest) { + AMFArrayValue array; + array.Insert("CString", "string"); + array.Insert("String", std::string("string")); + array.Insert("False", false); + array.Insert("True", true); + array.Insert("Integer", 42U); + array.Insert("Double", 42.0); + array.InsertArray("Array"); + array.Insert>("Undefined", {}); + array.Insert("Null", nullptr); + + std::cout << "test" << std::endl; + ASSERT_EQ(array.Get("CString")->GetValueType(), eAmf::String); + std::cout << "test" << std::endl; + ASSERT_EQ(array.Get("String")->GetValueType(), eAmf::String); + std::cout << "test" << std::endl; + ASSERT_EQ(array.Get("False")->GetValueType(), eAmf::False); + std::cout << "test" << std::endl; + ASSERT_EQ(array.Get("True")->GetValueType(), eAmf::True); + std::cout << "test" << std::endl; + ASSERT_EQ(array.Get("Integer")->GetValueType(), eAmf::Integer); + std::cout << "test" << std::endl; + ASSERT_EQ(array.Get("Double")->GetValueType(), eAmf::Double); + std::cout << "test" << std::endl; + ASSERT_EQ(array.GetArray("Array")->GetValueType(), eAmf::Array); + std::cout << "test" << std::endl; + ASSERT_EQ(array.Get("Null")->GetValueType(), eAmf::Null); + std::cout << "test" << std::endl; + ASSERT_EQ(array.Get>("Undefined")->GetValueType(), eAmf::Undefined); + std::cout << "test" << std::endl; +} + +TEST(dCommonTests, AMF3InsertionDenseTest) { + AMFArrayValue array; + array.Push("string"); + array.Push("CString"); + array.Push(false); + array.Push(true); + array.Push(42U); + array.Push(42.0); + array.PushArray(); + array.Push(nullptr); + array.Push>({}); + + ASSERT_EQ(array.Get(0)->GetValueType(), eAmf::String); + ASSERT_EQ(array.Get(1)->GetValueType(), eAmf::String); + ASSERT_EQ(array.Get(2)->GetValueType(), eAmf::False); + ASSERT_EQ(array.Get(3)->GetValueType(), eAmf::True); + ASSERT_EQ(array.Get(4)->GetValueType(), eAmf::Integer); + ASSERT_EQ(array.Get(5)->GetValueType(), eAmf::Double); + ASSERT_EQ(array.GetArray(6)->GetValueType(), eAmf::Array); + ASSERT_EQ(array.Get(7)->GetValueType(), eAmf::Null); + ASSERT_EQ(array.Get>(8)->GetValueType(), eAmf::Undefined); +} diff --git a/tests/dCommonTests/CMakeLists.txt b/tests/dCommonTests/CMakeLists.txt index 86c00c58..a345863d 100644 --- a/tests/dCommonTests/CMakeLists.txt +++ b/tests/dCommonTests/CMakeLists.txt @@ -1,8 +1,11 @@ set(DCOMMONTEST_SOURCES "AMFDeserializeTests.cpp" + "Amf3Tests.cpp" + "HeaderSkipTest.cpp" "TestLDFFormat.cpp" "TestNiPoint3.cpp" "TestEncoding.cpp" + "dCommonDependencies.cpp" ) # Set our executable diff --git a/tests/dCommonTests/HeaderSkipTest.cpp b/tests/dCommonTests/HeaderSkipTest.cpp new file mode 100644 index 00000000..a8f78078 --- /dev/null +++ b/tests/dCommonTests/HeaderSkipTest.cpp @@ -0,0 +1,37 @@ +#include + +#include "dCommonDependencies.h" +#include "dCommonVars.h" +#include "BitStream.h" + +#define PacketUniquePtr std::unique_ptr + +TEST(dCommonTests, HeaderSkipExcessTest) { + PacketUniquePtr packet = std::make_unique(); + unsigned char headerAndData[] = { 0x53, 0x02, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00 }; // positive + packet->data = headerAndData; + packet->length = sizeof(headerAndData); + CINSTREAM_SKIP_HEADER; + ASSERT_EQ(inStream.GetNumberOfUnreadBits(), 64); + ASSERT_EQ(inStream.GetNumberOfBitsAllocated(), 128); +} + +TEST(dCommonTests, HeaderSkipExactDataTest) { + PacketUniquePtr packet = std::make_unique(); + unsigned char header[] = { 0x53, 0x02, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00 }; // positive + packet->data = header; + packet->length = sizeof(header); + CINSTREAM_SKIP_HEADER; + ASSERT_EQ(inStream.GetNumberOfUnreadBits(), 0); + ASSERT_EQ(inStream.GetNumberOfBitsAllocated(), 64); +} + +TEST(dCommonTests, HeaderSkipNotEnoughDataTest) { + PacketUniquePtr packet = std::make_unique(); + unsigned char notEnoughData[] = { 0x53, 0x02, 0x00, 0x07, 0x00, 0x00 }; // negative + packet->data = notEnoughData; + packet->length = sizeof(notEnoughData); + CINSTREAM_SKIP_HEADER; + ASSERT_EQ(inStream.GetNumberOfUnreadBits(), 0); + ASSERT_EQ(inStream.GetNumberOfBitsAllocated(), 48); +} diff --git a/tests/dCommonTests/TestLDFFormat.cpp b/tests/dCommonTests/TestLDFFormat.cpp index 647c3cbf..36326e38 100644 --- a/tests/dCommonTests/TestLDFFormat.cpp +++ b/tests/dCommonTests/TestLDFFormat.cpp @@ -1,25 +1,252 @@ #include "LDFFormat.h" + #include -/** - * @brief Test parsing an LDF value - */ -TEST(dCommonTests, LDFTest) { - // Create - auto* data = LDFBaseData::DataFromString("KEY=0:VALUE"); +#include "Game.h" +#include "dCommonDependencies.h" +#include "dLogger.h" - // Check that the data type is correct +class LDFTests : public dCommonDependenciesTest { +protected: + void SetUp() override { + SetUpDependencies(); + } + + void TearDown() override { + TearDownDependencies(); + } +}; + +#define LdfUniquePtr std::unique_ptr + +// Suite of tests for parsing LDF values + +TEST_F(LDFTests, LDFUTF16Test) { + std::string testWord = "KEY=0:IAmA weird string with :::: and spac,./;'][\\es that I expect to be parsed correctly...; "; + LdfUniquePtr data(LDFBaseData::DataFromString(testWord)); + ASSERT_NE(data, nullptr); ASSERT_EQ(data->GetValueType(), eLDFType::LDF_TYPE_UTF_16); - - // Check that the key is correct ASSERT_EQ(data->GetKey(), u"KEY"); - - // Check that the value is correct - ASSERT_EQ(((LDFData*)data)->GetValue(), u"VALUE"); - - // Check that the serialization is correct - ASSERT_EQ(data->GetString(), "KEY=0:VALUE"); - - // Cleanup the object - delete data; + ASSERT_EQ(((LDFData*)data.get())->GetValue(), u"IAmA weird string with :::: and spac,./;'][\\es that I expect to be parsed correctly...; "); + ASSERT_EQ(data->GetString(), testWord); } + +TEST_F(LDFTests, LDFUTF16EmptyTest) { + std::string testWord = "KEY=0:"; + LdfUniquePtr data(LDFBaseData::DataFromString(testWord)); + ASSERT_NE(data, nullptr); + ASSERT_EQ(data->GetValueType(), eLDFType::LDF_TYPE_UTF_16); + ASSERT_EQ(data->GetKey(), u"KEY"); + ASSERT_EQ(((LDFData*)data.get())->GetValue(), u""); + ASSERT_EQ(data->GetString(), testWord); +} + +TEST_F(LDFTests, LDFUTF16ColonTest) { + std::string testWord = "KEY=0:::"; + LdfUniquePtr data(LDFBaseData::DataFromString(testWord)); + ASSERT_NE(data, nullptr); + ASSERT_EQ(data->GetValueType(), eLDFType::LDF_TYPE_UTF_16); + ASSERT_EQ(data->GetKey(), u"KEY"); + ASSERT_EQ(((LDFData*)data.get())->GetValue(), u"::"); + ASSERT_EQ(data->GetString(), testWord); +} + +TEST_F(LDFTests, LDFUTF16EqualsTest) { + std::string testWord = "KEY=0:=="; + LdfUniquePtr data(LDFBaseData::DataFromString(testWord)); + ASSERT_NE(data, nullptr); + ASSERT_EQ(data->GetValueType(), eLDFType::LDF_TYPE_UTF_16); + ASSERT_EQ(data->GetKey(), u"KEY"); + ASSERT_EQ(((LDFData*)data.get())->GetValue(), u"=="); + ASSERT_EQ(data->GetString(), testWord); +} + +TEST_F(LDFTests, LDFS32Test) { + LdfUniquePtr data(LDFBaseData::DataFromString("KEY=1:-15")); + ASSERT_NE(data, nullptr); + ASSERT_EQ(data->GetValueType(), eLDFType::LDF_TYPE_S32); + ASSERT_EQ(data->GetKey(), u"KEY"); + ASSERT_EQ(((LDFData*)data.get())->GetValue(), -15); + ASSERT_EQ(data->GetString(), "KEY=1:-15"); +} +TEST_F(LDFTests, LDFU32Test) { + LdfUniquePtr data(LDFBaseData::DataFromString("KEY=5:15")); + ASSERT_NE(data, nullptr); + ASSERT_EQ(data->GetValueType(), eLDFType::LDF_TYPE_U32); + ASSERT_EQ(data->GetKey(), u"KEY"); + ASSERT_EQ(((LDFData*)data.get())->GetValue(), 15); + ASSERT_EQ(data->GetString(), "KEY=5:15"); +} + +TEST_F(LDFTests, LDFU32TrueTest) { + LdfUniquePtr data(LDFBaseData::DataFromString("KEY=5:true")); + ASSERT_NE(data, nullptr); + ASSERT_EQ(data->GetValueType(), eLDFType::LDF_TYPE_U32); + ASSERT_EQ(data->GetKey(), u"KEY"); + ASSERT_EQ(((LDFData*)data.get())->GetValue(), 1); + ASSERT_EQ(data->GetString(), "KEY=5:1"); +} + +TEST_F(LDFTests, LDFU32FalseTest) { + LdfUniquePtr data(LDFBaseData::DataFromString("KEY=5:false")); + ASSERT_NE(data, nullptr); + ASSERT_EQ(data->GetValueType(), eLDFType::LDF_TYPE_U32); + ASSERT_EQ(data->GetKey(), u"KEY"); + ASSERT_EQ(((LDFData*)data.get())->GetValue(), 0); + ASSERT_EQ(data->GetString(), "KEY=5:0"); +} + + +// Use find since floats and doubles generally have appended 0s +TEST_F(LDFTests, LDFFloatTest) { + LdfUniquePtr data(LDFBaseData::DataFromString("KEY=3:15.5")); + ASSERT_NE(data, nullptr); + ASSERT_EQ(data->GetValueType(), eLDFType::LDF_TYPE_FLOAT); + ASSERT_EQ(data->GetKey(), u"KEY"); + ASSERT_EQ(((LDFData*)data.get())->GetValue(), 15.5f); + ASSERT_EQ(data->GetString().find("KEY=3:15.5"), 0); +} + +TEST_F(LDFTests, LDFDoubleTest) { + LdfUniquePtr data(LDFBaseData::DataFromString("KEY=4:15.5")); + ASSERT_NE(data, nullptr); + ASSERT_EQ(data->GetValueType(), eLDFType::LDF_TYPE_DOUBLE); + ASSERT_EQ(data->GetKey(), u"KEY"); + ASSERT_EQ(((LDFData*)data.get())->GetValue(), 15.5); + ASSERT_EQ(data->GetString().find("KEY=4:15.5"), 0); +} + + +TEST_F(LDFTests, LDFBoolTrueTest) { + LdfUniquePtr data(LDFBaseData::DataFromString("KEY=7:true")); + ASSERT_NE(data, nullptr); + ASSERT_EQ(data->GetValueType(), eLDFType::LDF_TYPE_BOOLEAN); + ASSERT_EQ(data->GetKey(), u"KEY"); + ASSERT_EQ(((LDFData*)data.get())->GetValue(), true); + ASSERT_EQ(data->GetString(), "KEY=7:1"); +} + +TEST_F(LDFTests, LDFBoolFalseTest) { + LdfUniquePtr data(LDFBaseData::DataFromString("KEY=7:false")); + ASSERT_NE(data, nullptr); + ASSERT_EQ(data->GetValueType(), eLDFType::LDF_TYPE_BOOLEAN); + ASSERT_EQ(data->GetKey(), u"KEY"); + ASSERT_EQ(((LDFData*)data.get())->GetValue(), false); + ASSERT_EQ(data->GetString(), "KEY=7:0"); +} + +TEST_F(LDFTests, LDFBoolIntTest) { + LdfUniquePtr data(LDFBaseData::DataFromString("KEY=7:3")); + ASSERT_NE(data, nullptr); + ASSERT_EQ(data->GetValueType(), eLDFType::LDF_TYPE_BOOLEAN); + ASSERT_EQ(data->GetKey(), u"KEY"); + ASSERT_EQ(((LDFData*)data.get())->GetValue(), true); + ASSERT_EQ(data->GetString(), "KEY=7:1"); +} + +TEST_F(LDFTests, LDFU64Test) { + LdfUniquePtr data(LDFBaseData::DataFromString("KEY=8:15")); + ASSERT_NE(data, nullptr); + ASSERT_EQ(data->GetValueType(), eLDFType::LDF_TYPE_U64); + ASSERT_EQ(data->GetKey(), u"KEY"); + ASSERT_EQ(((LDFData*)data.get())->GetValue(), 15); + ASSERT_EQ(data->GetString(), "KEY=8:15"); +} + +TEST_F(LDFTests, LDFLWOOBJIDTest) { + LdfUniquePtr data(LDFBaseData::DataFromString("KEY=9:15")); + ASSERT_NE(data, nullptr); + ASSERT_EQ(data->GetValueType(), eLDFType::LDF_TYPE_OBJID); + ASSERT_EQ(data->GetKey(), u"KEY"); + ASSERT_EQ(((LDFData*)data.get())->GetValue(), 15); + ASSERT_EQ(data->GetString(), "KEY=9:15"); +} + +TEST_F(LDFTests, LDFUTF8Test) { + std::string testWord = "KEY=13:IAmA weird string with :::: and spac,./;'][\\es that I expect to be parsed correctly...; "; + LdfUniquePtr data(LDFBaseData::DataFromString(testWord)); + ASSERT_NE(data, nullptr); + ASSERT_EQ(data->GetValueType(), eLDFType::LDF_TYPE_UTF_8); + ASSERT_EQ(data->GetKey(), u"KEY"); + ASSERT_EQ(((LDFData*)data.get())->GetValue(), "IAmA weird string with :::: and spac,./;'][\\es that I expect to be parsed correctly...; "); + ASSERT_EQ(data->GetString(), testWord); +} + +TEST_F(LDFTests, LDFUTF8EmptyTest) { + std::string testWord = "KEY=13:"; + LdfUniquePtr data(LDFBaseData::DataFromString(testWord)); + ASSERT_NE(data, nullptr); + ASSERT_EQ(data->GetValueType(), eLDFType::LDF_TYPE_UTF_8); + ASSERT_EQ(data->GetKey(), u"KEY"); + ASSERT_EQ(((LDFData*)data.get())->GetValue(), ""); + ASSERT_EQ(data->GetString(), testWord); +} + +TEST_F(LDFTests, LDFUTF8ColonsTest) { + std::string testWord = "KEY=13:::"; + LdfUniquePtr data(LDFBaseData::DataFromString(testWord)); + ASSERT_NE(data, nullptr); + ASSERT_EQ(data->GetValueType(), eLDFType::LDF_TYPE_UTF_8); + ASSERT_EQ(data->GetKey(), u"KEY"); + ASSERT_EQ(((LDFData*)data.get())->GetValue(), "::"); + ASSERT_EQ(data->GetString(), testWord); +} +TEST_F(LDFTests, LDFUTF8EqualsTest) { + std::string testWord = "KEY=13:=="; + LdfUniquePtr data(LDFBaseData::DataFromString(testWord)); + ASSERT_NE(data, nullptr); + ASSERT_EQ(data->GetValueType(), eLDFType::LDF_TYPE_UTF_8); + ASSERT_EQ(data->GetKey(), u"KEY"); + ASSERT_EQ(((LDFData*)data.get())->GetValue(), "=="); + ASSERT_EQ(data->GetString(), testWord); +} + + +TEST_F(LDFTests, LDFParseEdgeCaseTest) { + std::vector tests = { + // Test undefined data + "", // Empty + "=", // Only equals sign + ":", // Only colon + "=:", // Only colon and equals sign + + // Test no LDFType + "KEY=:", // No LDF Type + "KEY=:44", // No LDF Type, but has value + + // Test invalid values, but valid types + "key=1:", // no value for int32 + "key=1:banana", // invalid value for int32 + "key=3:", // No value for float + "key=3:banana", // invalid for float + "key=4:", // No value for double + "key=4:banana", // invalid for double + "key=5:", // No value for U32 + "key=5:banana", // invalid for U32 + "key=7:", // No value for bool + "key=7:banana", // invalid for bool + "key=8:", // No value for U64 + "key=8:banana", // invalid for U64 + "key=9:", // No value for LWOOBJID + "key=9:banana", // invalid for LWOOBJID + + // Test invalid LDF types + "key=14:value", // invalid LDF type + "key=-1:value", // invalid LDF type + "key=-2:value", // invalid LDF type (no enum definition) + "key=Garbage:value", // invalid LDF type + }; + for (auto testString : tests) { + Game::logger->Log("LDFTests", "Testing LDF Parsing of invalid string (%s)", testString.c_str()); + EXPECT_NO_THROW(LDFBaseData::DataFromString(testString)); + } +} + +#ifdef PERF_TEST + +TEST_F(LDFTests, LDFSpeedTest) { + std::string keyToTest = "KEY=0:IAmA weird string with :::: and s"; + for (int i = 0; i < 10000; i++) LDFBaseData::DataFromString(keyToTest); +} + +#endif //PERF diff --git a/tests/dCommonTests/dCommonDependencies.cpp b/tests/dCommonTests/dCommonDependencies.cpp new file mode 100644 index 00000000..5b25fd47 --- /dev/null +++ b/tests/dCommonTests/dCommonDependencies.cpp @@ -0,0 +1,7 @@ +#include "Game.h" + +class dLogger; +namespace Game +{ + dLogger* logger; +} // namespace Game diff --git a/tests/dCommonTests/dCommonDependencies.h b/tests/dCommonTests/dCommonDependencies.h new file mode 100644 index 00000000..12aeb938 --- /dev/null +++ b/tests/dCommonTests/dCommonDependencies.h @@ -0,0 +1,26 @@ +#ifndef __DCOMMONDEPENDENCIES__H__ +#define __DCOMMONDEPENDENCIES__H__ + +#include "Game.h" +#include "dLogger.h" +#include "dServer.h" +#include "EntityInfo.h" +#include "EntityManager.h" +#include "dConfig.h" +#include + +class dCommonDependenciesTest : public ::testing::Test { +protected: + void SetUpDependencies() { + Game::logger = new dLogger("./testing.log", true, true); + } + + void TearDownDependencies() { + if (Game::logger) { + Game::logger->Flush(); + delete Game::logger; + } + } +}; + +#endif //!__DCOMMONDEPENDENCIES__H__ diff --git a/tests/dGameTests/dComponentsTests/DestroyableComponentTests.cpp b/tests/dGameTests/dComponentsTests/DestroyableComponentTests.cpp index 7399456d..db9c033a 100644 --- a/tests/dGameTests/dComponentsTests/DestroyableComponentTests.cpp +++ b/tests/dGameTests/dComponentsTests/DestroyableComponentTests.cpp @@ -5,6 +5,7 @@ #include "DestroyableComponent.h" #include "Entity.h" #include "eReplicaComponentType.h" +#include "eStateChangeType.h" class DestroyableTest : public GameDependenciesTest { protected: diff --git a/tests/dGameTests/dGameMessagesTests/GameMessageTests.cpp b/tests/dGameTests/dGameMessagesTests/GameMessageTests.cpp index 631f0d2d..047f56d6 100644 --- a/tests/dGameTests/dGameMessagesTests/GameMessageTests.cpp +++ b/tests/dGameTests/dGameMessagesTests/GameMessageTests.cpp @@ -1,5 +1,5 @@ #include "Action.h" -#include "AMFFormat.h" +#include "Amf3.h" #include "AMFDeserialize.h" #include "GameMessages.h" #include "GameDependencies.h" @@ -40,8 +40,8 @@ protected: } AMFArrayValue* ReadArrayFromBitStream(RakNet::BitStream* inStream) { AMFDeserialize des; - AMFValue* readArray = des.Read(inStream); - EXPECT_EQ(readArray->GetValueType(), AMFValueType::AMFArray); + AMFBaseValue* readArray = des.Read(inStream); + EXPECT_EQ(readArray->GetValueType(), eAmf::Array); return static_cast(readArray); } }; diff --git a/vanity/NPC.xml b/vanity/NPC.xml index 3bb5ae9f..2311ab46 100644 --- a/vanity/NPC.xml +++ b/vanity/NPC.xml @@ -17,6 +17,19 @@ + + 12947, 12949, 12962, 12963 + + I hope quickbulds are still working! + Be careful crossing the gap! + Have The Maelstrom stopped going invisible? + + + + + + + 9950, 9944, 14102, 14092