summaryrefslogtreecommitdiff
path: root/src/net
AgeCommit message (Collapse)AuthorFilesLines
10 daysUse a consistent naming style for enum class valuesThorbjørn Lindeijer12-49/+49
Sometimes I've used CamelCase and sometimes SNAKE_CASE for these values. Since "enum class" values are always prefixed with the enum name, which uses CamelCase, I find it more fitting to use it for the values as well. Also fixes compilation on Windows where 'ERROR' was conflicting with a define.
11 daysFixed crash on exit when CharCreateDialog is openThorbjørn Lindeijer1-5/+19
* Displayed Being was deleting its SpeechBubble after the WindowContainer had already deleted it. Resolved by registering a DeathListener. * On dialog deletion, the CharHandler had become a roaming pointer but was still accessed.
2025-03-13Removed needless case-insensitive string comparisonsThorbjørn Lindeijer2-5/+4
These are not necessary since we can instead make sure the referenced values match case, like we do for everything else. This affects server types in the server list and colors referenced in theme files. The server version was also compared case-insensitively for some reason.
2025-03-07Removed the functionality to split item stacksThorbjørn Lindeijer7-20/+0
No longer supported by manaserv and not supported by tmwAthena.
2025-03-07General code cleanupsThorbjørn Lindeijer5-32/+19
2025-03-07Fixed GeneralHandler deletion when switching server typesThorbjørn Lindeijer10-51/+31
When switching between tmwAthena and Manaserv the GeneralHandler was not getting deleted, resulting in crashes later on when the still around instance (or one of its child handlers) would try to respond to events it was listening to.
2025-03-07Fixed handling of equipmentThorbjørn Lindeijer3-18/+34
* Fixed ManaServ::EquipBackend removing all slots in response to GPMSG_INVENTORY_FULL, rather than resetting them to empty. * Fixed updating of buttons in InventoryWindow as relevant from the ManaServ::InventoryHandler. * Updated handling of equipment sprites in messages related to character appearance (Manaserv now always sends all relevant equipment and as such does not send removals).
2025-03-07Support triggering attacks and play use ability animationsThorbjørn Lindeijer2-10/+38
For now, PlayerHandler::attack just tries to trigger the "Strike" ability. Adjusted the AbilityDB to the removal of ability categories and the addition of the useaction attribute (mana/manaserv@81f126ae001b1446dc0be37341f133dca5ab2923)
2025-03-07Updated manaserv protocol to version 9Thorbjørn Lindeijer17-412/+371
This extends the messages regarding abilities, replacing the specific "attack" messages. It also unifies attribute handling, with a generic system replacing specific variables for attributes like level, xp and skills. The inventory and equipment handling was adjusted such that equipped items stay in the inventory. Support for quest states was added. Added: * GPMSG_ABILITY_REMOVED (mana/manaserv@e3fcc1a47db312933a0f5b7e725c5779a1a45722) * GPMSG_ABILITY_COOLDOWN (mana/manaserv@c2f00b2f3ba920cb25333d19a1d37d251342caf8) * GPMSG_BEING_ABILITY_POINT * GPMSG_BEING_ABILITY_BEING (mana/manaserv@2f2393b6d190deb8958fcb806b58418508d25e28) * GPMSG_ATTRIBUTE_POINTS_STATUS (mana/manaserv@1e5a15c0a5e24fb4b358fff75a7082d65496e1f9) * PGMSG_USE_ABILITY_ON_DIRECTION (mana/manaserv@05fc955a3f8a03539088fa7569395434e29d90e8) * GPMSG_BEING_ABILITY_DIRECTION (mana/manaserv@54389afd7ba9fecf0761333185145e968e2453ae) * GPMSG_QUESTLOG_STATUS (mana/manaserv@66a98a3a0df795761328d62ef2ad07f81e383f9e) Removed: * PGMSG_ATTACK * GPMSG_BEING_ATTACK (mana/manaserv@f31277b327df701361391b1d4b8bd6f89f4e3109) * GPMSG_PLAYER_EXP_CHANGE * GPMSG_LEVELUP * GPMSG_LEVEL_PROGRESS (mana/manaserv@44ee071d7ece5a2023f79307f36e8a244c9e7b3a) Changed: * GPMSG_ABILITY_STATUS (mana/manaserv@ba573fcc38580a01985172b9bc864c97ce855af3) * GPMSG_BEING_LOOKS_CHANGE (mana/manaserv@8ddda85d923a528c7497a628d2fe10fc40b80a1f) * APMSG_CHAR_INFO (mana/manaserv@4f5053f463fd8da0de1615ca6b0f212f02f3d653) * APMSG_CHAR_CREATE_RESPONSE (mana/manaserv@1263c729d85df649c7ab59726bddad7c8cd7ae81) * GPMSG_NPC_BUYSELL_RESPONSE (mana/manaserv@336ce321a9b996e56a61a5364bb32124efa84dd9) Equipment changes (mana/manaserv@f712d68495dd8e040c32da3b1c85bcb7845543ec): * Changed GPMSG_INVENTORY_FULL, GPMSG_EQUIP * Removed PGMSG_MOVE_ITEM * Added GPMSG_EQUIP_RESPONSE, GPMSG_UNEQUIP_RESPONSE, GPMSG_UNEQUIP While this change deals with some of the protocol changes, there's still many changes required in the UI regarding using of abilities (including attacking), showing of certain attributes and quest log.
2025-03-07Ability related network message adjustmentsThorbjørn Lindeijer2-2/+9
* Handle GPMSG_ABILITY_REMOVED for removal of abilities (mana/manaserv@e3fcc1a47db312933a0f5b7e725c5779a1a45722) * Adjust GPMSG_ABILITY_STATUS now that it only sends abilities that have changed state, so it should no longer clear all abilities. (mana/manaserv@3598685c0fcbb9b5fdbcdbbaee258e2b55d5c98a)
2025-03-07Renamed specials to abilitiesThorbjørn Lindeijer13-51/+51
To match mana/manaserv@9ff69160ea1c3c64ea7012cd70a3b50ff4373264.
2025-03-01Further Download related cleanupsThorbjørn Lindeijer3-75/+117
* Moved the memory buffer and mutex handling into the Download class to simplify the code updating the UI in ServerDialog and UpdaterWindow. * Replaced the "DownloadUpdate" callback function with simply polling Download::getState, since in the end polling was happening anyway. This changes also fixes handling of the Enter key while downloading updates, which no longer cancels the update process. Also, when pressing Escape while things are being downloaded, the first press cancels and only the second press goes back to login. Introduced a ThreadSafe template class, which wraps any type and makes it only accessible by calling lock(). This ensures the data is never accessed without locking the relevant mutex.
2025-02-26Plugged various memory leaksThorbjørn Lindeijer1-1/+1
* ActorSpriteManager failed to delete its AutoCompleteLister instances. * CharCreateDialog was relying on ~Window to delete its child widgets, but it wasn't always adding all its widgets, so some failed to get deleted. Now it only creates the widgets it needs. * SkillDialog didn't delete its SkillModels. * PlayerList didn't delete its player Avatar instances. * Fixed deletion of the EffectManager. Leaks located using AddressSanitizer.
2025-02-26Cleanup Download code, fixing SDL_Thread leakingThorbjørn Lindeijer2-159/+124
The download thread was setting itself to nullptr (d->mThread = nullptr) in a number of locations. This caused a later call to SDL_WaitThread to be unable to perform cleanup. This reverts most of 1eb02f83a5d3895e4e18db30ea10d88da94ba4c0 (including making Download::cancel no longer blocking), but keeps the necessary waiting for the thread to finish before freeing the memory buffer in ~UpdaterWindow(), which might have been the bug fixed by that change. Fixed removal of downloaded .part file when its checksum failed. It trying to remove the file without .part appended instead. Fixed download progress indication in ServerDialog to not be reversed, though this is rarely visible due to the server list being so small. Fixed reporting of curl error.
2025-02-25Added support for option, opt1, opt2, opt3 status effect fieldsThorbjørn Lindeijer1-24/+56
Supporting these fields is necessary to correctly identify status effects sent by tmwAthena. This is a manual port of ac4e40a1408ad4d6fbcfce9d2bc6a0bc187ea5a4, 542d2ba78d84e0fa051e0620ccab5fb3a0c711e3 and 8800940bb4b94f6dab7dcf80bf0abc3e3b09e35f from M+.
2025-02-14Fixed handling of update URLs which mention a portThorbjørn Lindeijer1-5/+3
This appears to have been a regression in f405849b49614254f42eb3ee6147434458978623, which for some reason erased the port (and any trailing parts) from not just the update directory but also from the update URL. Unfortunately we can't access Mana-Mantis #381 at the moment, but presumably the port was removed due to the colon being a problematic character. Instead, now the colon (and other special characters) are replaced by _ when determining the update directory. Closes https://git.themanaworld.org/mana/mana/-/issues/80
2025-02-13TMWA: Reduce magic numbers when converting directionThorbjørn Lindeijer2-29/+28
2025-02-13Support changing being base typeThorbjørn Lindeijer4-30/+58
The GM command @class (alias @charclass) can be used by GMs to change their character class (also referred to as job, race, base or species). Changes of the class are now supported, even supporting switching between appearing as player, monster or NPC. Part of https://git.themanaworld.org/mana/mana/-/issues/92
2025-01-21Replaced include guards with #pragma onceThorbjørn Lindeijer68-272/+70
Thanks to https://github.com/cgmb/guardonce and a follow-up replace to remove duplicated newlines at end of file: find src -type f -name '*.h' -exec \ sed --in-place -e :a -e '/^\n*$/{$d;N;};/\n$/ba' {} \; Source: https://unix.stackexchange.com/questions/81685/how-to-remove-multiple-newlines-at-eof Fixes compile on macOS, which appears to have been due to the EVENT_H include guard.
2025-01-20Made client config statically typedThorbjørn Lindeijer3-6/+5
This makes accessing the config values much faster, since it no longer needs to do a lookup nor string conversion, which means we could remove some needless copying of the values. Overall it makes it easier to find out where settings are used and it puts the defaults along with the declaration. Options with default values are no longer saved to the config file. This does not include unrecognized options, which are kept around to provide some compatibility with older clients. While most basic options have kept the same name, more complicated settings like window geometry, shortcuts, outfits, etc. now have their own XML elements. Older clients will ignore these and erase them when saving the configuration.
2025-01-20Wrapped xmlNodePtr access with a Node classThorbjørn Lindeijer2-17/+17
Slightly more ergonomic and this eliminates direct libxml2 usage from many places.
2024-12-20Read whole packet SMSG_MAP_QUIT_RESPONSE.Andrei Karas1-1/+1
2024-10-29Turned the PlayerRelation struct into an enum classThorbjørn Lindeijer4-10/+10
Less code to achieve the same thing (strong type and namespaced values). The permissions related values have been moved to a PlayerPermissions struct, which is also a bit less confusing.
2024-10-23Changed SERVER_NOTICE macro to inline functionThorbjørn Lindeijer13-105/+95
Seems to be no point in using a macro here.
2024-10-23Various small fixes to translatable stringsThorbjørn Lindeijer5-10/+13
Mostly adjustments based on feedback from the Finnish translator.
2024-10-18General code cleanupsThorbjørn Lindeijer3-5/+3
2024-10-12Added support for hit/miss sounds on equipment for all playersThorbjørn Lindeijer1-5/+1
Previously only the local player's weapon "strike" sound would play, regardless of hit or miss. Now the sound is played in response to the SMSG_BEING_ACTION message, so it can be played for all players. Also added alias "miss", which is used by TMW in some places. Finally, when no weapon is equipped, it falls back to the sounds defined on the racesprite item (fixes punch sound on TMW). Closes #68
2024-10-08Do a single logic update each frameThorbjørn Lindeijer5-20/+17
The logic update now uses Time::deltaTimeMs() where needed to make it framerate-independent. This means there will no longer be multiple logic calls per frame (as was usually the case with logic ticking at 100 fps whereas the game would generally run at 60 fps). At the same time, the game can be more precise at higher framerates and should now run smoother at 144 Hz, for example. Previously the game would sometimes skip logic ticks at that rate. This change affects: * Updating of animations * Being movement speed * More moving of manual time variables to Timer Notoriously, the particle system still does 100 ticks/second.
2024-10-08Added convenient and efficient Timer classThorbjørn Lindeijer1-4/+5
The Timer is efficient because it does not depend on incrementing a counter to keep track of time, nor does it call SDL_GetTicks every time its state is checked (this happens once per frame instead). Along with global functions Time::absoluteTimeMs() and Time::deltaTimeMs(), this replaces previous globals tick_time, cur_time and get_elapsed_time(). For now, there is still a fixed 100 times per second logic call rate, but the new Time::deltaTimeMs() function should allow getting rid of this.
2024-09-27Replaced for_each_xml_child_node macro with helper classThorbjørn Lindeijer1-2/+2
The new XML::Children class enables using a C++11 range-based for loop to iterate over the children of an xmlNodePtr.
2024-08-25Fixed initialization of equipment backendThorbjørn Lindeijer5-58/+37
For new characters (and in general, when logging in with a character that had nothing equipped), the equipment backend wasn't being initialized. This resulted in the equipment not being visible in the Equipment window. Fixes #83
2024-08-04Removed a bunch of unused NPC related eventsThorbjørn Lindeijer2-60/+0
Nobody cared for the events that were emitted when NPC related network messages had been sent.
2024-06-25Added online player list to Social windowDavid Athay5-1/+41
The online list refreshes every 18 seconds, which matches ManaVerse behavior. It's not ideal, but to improve this would mean diving into TMWA. The client version was bumped to 8 to get a SMSG_ONLINE_LIST reply. Further changes needed related to the client version are tracked by #71. This also changes the TabbedArea to take into account the frame size for its tab widgets, to make sure those frames are not clipped by the TabbedArea widget (as happened in the Social window). The horizontal scroll bar is now disabled in all social tabs, with the vertical one appearing only when necessary. Closes #61
2024-06-03Added handling of SMSG_SCRIPT_MESSAGEThorbjørn Lindeijer1-0/+13
These are server chat messages triggered from scripts. In TMW this appears to be used only by the magic system. Added in client protocol version 5 (see issue #71).
2024-04-18Simplify TmwAthena::MessageOutThorbjørn Lindeijer5-84/+27
Since for tmwAthena we're writing messages directly into the output buffer, the MessageOut implementation does not need any members. Also used SDL_SwapLE16 and SDL_SwapLE32 for convenience.
2024-04-02General code cleanupsThorbjørn Lindeijer1-4/+2
* Removed some unused includes * Removed unused ListBox::mFont * Removed wrong cast to SDL_Scancode * Removed superfluous .c_str() * Removed superfluous explicit std::string construction * Removed unused variable * Use more emplace_back * Turned FindBeingFunctor into a lambda * Avoid needless pointer references for ambient layers and use a vector
2024-03-13Adjusted handling of SMSG_LOGIN_DATA to what tmwa sendsThorbjørn Lindeijer1-3/+4
2024-03-12General code cleanupsThorbjørn Lindeijer4-13/+1
* Use default member initializers * Use range-based for loops * Avoid needless pointer references for ShopItem::mDuplicates * Removed type aliases that are only used once or twice * Removed more unused includes * Removed some unused functions * Removed superfluous .c_str() * Rely on default copy and assignment operators for Vector class * Use std::unique_ptr in some places * Removed duplicated mPlayerMoney updating in SellDialog * Removed duplicated Game::handleInput call * Removed unused SDLInput::mMouseInWindow * Removed remnant of manual widget positioning in HelpWindow * Removed superfluous initialization of static pointers
2024-03-06General code cleanupsThorbjørn Lindeijer41-88/+58
* Use final for all message handlers, Client, LocalPlayer, Being::getType, Being::setPosition and Being::setMap. (avoids some warnings about virtual dispatch in constructors) * Use auto in more places * Use emplace_back instead of push_back in some places * Use default member initializers * Less else after return * Removed superfluous .c_str() * Removed type aliases that are only used once * Removed more unused includes
2024-03-04Fixed character displayThorbjørn Lindeijer11-45/+85
This change fixes hair style to take into account "race", which makes the faces visible again. Hair colors should also be fixed now, with partial support for itemcolors.xml added. The Mana client now also supports per-character gender, and it now hides the hair style and color buttons on character creation, when there are none to choose from. Closes #43
2024-03-04Added support for handling SMSG_NPC_COMMANDThorbjørn Lindeijer2-26/+82
This only adds support for the NPC_CLOSE_DIALOG and NPC_CLEAR_DIALOG sub-commands. Closes #47
2024-03-04Fixed duplication of player name in chatThorbjørn Lindeijer3-15/+39
* Fixed duplication of player name in chat Closes #49
2024-03-02Changed server type to "enum class"Thorbjørn Lindeijer3-34/+35
2024-03-02Added support for -y / --server-type parameterThorbjørn Lindeijer4-11/+21
Usually this would be guessed correctly by the port, but now it is also possible to just specify the server type and the port will be derived from there, unless a default port is given in the branding file. Closes #56
2024-02-29Re-download updates when their checksum no longer matchesThorbjørn Lindeijer2-29/+27
The Mana World currently likes to just update its "TMW.zip" file, whereas updates were always given unique names in the past. With this change, the client checks the Adler32 checksum to know when it should re-download an update file. This matches the behavior of ManaPlus commit 96150f1aeacf55d311c41ffe12d9e754b1cda001.
2024-02-22General code cleanupsThorbjørn Lindeijer19-69/+30
* Use default member initializers * Use range-based loops * Don't use 'else' after 'return' * Removed some unused includes * Construct empty strings with std::string() instead of "" * Clear strings with .clear() instead of assigning "" * Check whether strings are empty with .empty() instead of comparing to "" * Removed redundant initializations
2024-02-15Fix handling of non-consecutive emote IDsThorbjørn Lindeijer2-2/+2
Previous code was assuming there would be no gaps in the emote IDs. Also cleaned up some confusion where the "emote ID" being passed around in the code was often offset by 1. Now it is only offset in communication with tmwAthena and when saving the shortcuts.
2024-02-14Avoid crash when receiving SMSG_MAP_MASK without Game instanceThorbjørn Lindeijer1-2/+3
It happened to me a few times. Needs checking whether we could instead make sure we always have a Game instance when receiving this message, because this way a map mask might get ignored. Or maybe the map mask just needs to be stored elsewhere.
2024-02-13Updated tmwAthena network protocolThorbjørn Lindeijer20-492/+465
* The code defining the message IDs and sizes are now generated by the tools/protocol.py script in the tmwAthena repository. * Reduced client version from 20 to 6, because that is currently the minimum supported version, and any adjustments needed for later likely still need to be made. * Removed use of no longer handled messages: - CMSG_SKILL_USE_BEING - CMSG_SKILL_USE_POSITION - CMSG_SKILL_USE_MAP - SMSG_PARTY_MOVE - CMSG_WHO_REQUEST - SMSG_WHO_ANSWER - SMSG_MVP - SMSG_BEING_MOVE2 - SMSG_BEING_CHANGE_LOOKS * Some messages were renamed to match the server side - CMSG_PLAYER_ATTACK -> CMSG_PLAYER_CHANGE_ACT - CMSG_PLAYER_RESTART -> CMSG_PLAYER_REBOOT - SMSG_ADMIN_IP -> SMSG_BEING_IP_RESPONSE Part of addressing issues #55 and #47, which we now know are about handling SMSG_PLAYER_HP and SMSG_NPC_COMMAND respectively. The client will now ignore them (with a warning) instead of crash.
2024-02-13Removed guild handling remnants for tmwAthenaThorbjørn Lindeijer1-373/+1
This stuff was removed from tmwAthena, so it will never be supported.