summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2024-03-21Removed unused ResourceManager methodsThorbjørn Lindeijer2-43/+0
* ResourceManager::addResource * ResourceManager::get(const std::string &) These were once added in 32996cee607c52ecef9be4638df554dd89b39c24, but they are no longer necessary after the port to SDL2 (2c51c98625b225cecfb9628c30d62d4e30f7e3e1).
2024-03-21Removed the unused Image::mLoaded memberThorbjørn Lindeijer2-41/+19
2024-03-21Use std::function in ResourceManagerThorbjørn Lindeijer4-85/+35
Simplifies the code a little. Also use ResourceRef in SubImage to avoid manual reference counting.
2024-03-13Use snprintf instead of sprintfThorbjørn Lindeijer2-7/+7
Amendment of dd1db3753ecf8a4d782aee1f518759763d8caf87.
2024-03-13CI: Added macOS build jobThorbjørn Lindeijer1-0/+10
2024-03-13Adjusted handling of SMSG_LOGIN_DATA to what tmwa sendsThorbjørn Lindeijer1-3/+4
2024-03-13CI: Ensure we can compile on Ubuntu 20.04 as wellThorbjørn Lindeijer1-5/+8
Using DEBIAN_FRONTEND=noninteractive to avoid a timezone related prompt on Ubuntu 20.04. Also switched to apt-get, to avoid a warning about the CLI interface not being stable.
2024-03-13Added SDL version check for SDL_OpenURLThorbjørn Lindeijer2-5/+20
Ubuntu 20.04 had SDL 2.0.10, and it is still supported. Also added error handling to the SDL_OpenURL call, just in case.
2024-03-12General code cleanupsThorbjørn Lindeijer71-546/+250
* 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-11Implemented ability to open external links in news and chatThorbjørn Lindeijer9-18/+73
* Use ConfirmDialog to confirm the opening of the external link. * ConfirmDialog now centers on its parent window when provided. * Reset hovered link when mouse exits the BrowserBox.
2024-03-11Fixed settings being unavailable when updating was doneThorbjørn Lindeijer1-0/+1
The 'Play' button was continuously requesting focus once the updates had been downloaded.
2024-03-08Removed SDL2_gfx dependencyThorbjørn Lindeijer5-29/+52
Since the upgrade to SDL2 it was only used for framerate limiting, which I've replicated in a small helper class. Also reduced the framerate limit while minimized from 100 to 10 FPS.
2024-03-07Some code simplifications in ResourceManager::loadFileThorbjørn Lindeijer1-16/+9
2024-03-07Fixed ambient layers "keepratio" optionThorbjørn Lindeijer5-15/+27
I had broken this in 264be2108c51837fa92085f6c839e66aebbcfc9e by no longer reading out the property. Made some further simplifications and two more fixes: * When the original image's size was not 800x600, it wouldn't get scaled as expected due to the integer division being performed before the multiplication. * I had changed the default resolution to 1280x720, while mKeepRatio expects to scale the original image as if it was displayed on an 800x600 screen. So now it's hardcoded on 800x600 rather than using the defaultScreenWidth/Height variables. * Removed the confusing x/y parameters from AmbientLayer::draw, which were actually set to the graphics width/height. * Changed SDLGraphics::drawRescaledImagePattern to not repeatedly set the source origin.
2024-03-07Use the native TMX tile animation formatThorbjørn Lindeijer17-288/+247
Rewrote the tile animation loading code based on XML tags, replacing the code that loaded tile animations from tile properties. Also made a number of code simplifications and optimizations: * Replaced a number of pointer members with value members. * Pass around Animation and TileAnimation by value, using std::move to avoid allocating copies. * push -> emplace * push_front -> emplace_front * push_back -> emplace_back * Use range-based for loops * Use std::vector instead of std::list for storing affected tiles (less fragmentation) * Avoid string copies and allocations while parsing CSV layer data. * Replaced xmlNodeGetContent with directly accessing 'content'.
2024-03-07Fixed tile animations for CSV mapsThorbjørn Lindeijer2-6/+5
The affected tiles were only tracked for base64-encoded layer data.
2024-03-06General code cleanupsThorbjørn Lindeijer65-231/+136
* 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-04CI: Use Ninja to speed up compile timesThorbjørn Lindeijer2-3/+4
Ninja should automatically run the appropriate amount of parallel jobs. Also removed the --parallel from the README.md, since the default generator (Unix Makefiles) is not smart about this and risks locking up people's systems because the many compile jobs can make it run out of memory.
2024-03-04Fixed character displayThorbjørn Lindeijer22-107/+164
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 Lindeijer4-26/+94
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-02Exit with error when invalid server type is passed on CLIThorbjørn Lindeijer3-11/+17
Also made it exit with error when there is an unknown option or missing argument.
2024-03-02Changed server type to "enum class"Thorbjørn Lindeijer24-98/+86
2024-03-02Added support for -y / --server-type parameterThorbjørn Lindeijer12-54/+68
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-03-02Added support for customizing NPC and Monster hover cursorThorbjørn Lindeijer9-48/+82
To match support for this in M+, since TMW uses this functionality on two of its NPCs.
2024-03-02Updated mouse cursors to latest versionThorbjørn Lindeijer8-70/+67
The new cursor types are not used yet for now.
2024-03-02General code cleanupsThorbjørn Lindeijer22-213/+122
* Don't needlessly store or return raw pointers in BeingInfo * Less copying, more moving * Less else after return * Make AddDEF a template instead of a macro * Removed some unused includes * Use range-based for loops
2024-02-29Re-download updates when their checksum no longer matchesThorbjørn Lindeijer4-49/+43
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-28Use snprintf instead of sprintfThorbjørn Lindeijer1-5/+1
Using sprintf triggers a warning on macOS. The buffer should be large enough, but a little extra security doesn't hurt.
2024-02-27Added VSync and windowed fullscreen optionsThorbjørn Lindeijer20-784/+1068
The configuration and setup UI were adjusted to the new options. This also fixes issues in applying new video settings. Default resolution was changed from 800x600 to 1280x720. VSync is enabled by default while FPS limit was disabled. Display aspect ratio for the resolution options. I had to work around some macOS issues: * Don't change window size when it appears to be "maximized", since it just changes the rendering area while leaving the window maximized. * Unset fullscreen display mode temporarily to allow changing resolutions, otherwise the rendering area no longer matches the screen and mouse input is also off. * Removed SDL_WINDOW_ALLOW_HIGHDPI for now because it causes issues on macOS, since we're not actually handling the scaling factor. A Video class and an SDLGraphics subclass were split off from Graphics. This setup has Less duplication and leaves the OpenGLGraphics and SDLGraphics better separated. Fixes #57 Fixes #58
2024-02-22General code cleanupsThorbjørn Lindeijer75-362/+249
* 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-21Adjusted icon and desktop file names and added metainfoThorbjørn Lindeijer7-63/+122
2024-02-19Updated PhysicsFS API usageThorbjørn Lindeijer3-57/+24
Unfortunately, since we're making a difference between config and data, and also want to know where to write screenshots, we can't get rid of PHYSFS_getUserDir entirely. We'd need a replacement to get rid of the deprecation warnings. Also removed copying of old config file at "/.tmw/config.xml".
2024-02-19Fixed compile on macOSThorbjørn Lindeijer8-429/+52
Since Guichan is currently disabled on Homebrew, I've opted for adding it as a submodule instead. It currently references the 0.8 branch of Guichan, after I cherry-picked the CMake support from the master branch. When using SDL2 installed through Homebrew, it was necessary to use SDL2_LINK_LIBRARIES, since the libraries occupy various different directories. It no longer seems necessary to include an SDLMain.m, so I deleted it. Removed obsolete OS X instructions. Also added instructions for installing dependencies on Fedora. Removed mentioning of /announce and /who in the README, since they were removed for tmwAthena.
2024-02-15Fix handling of non-consecutive emote IDsThorbjørn Lindeijer15-170/+141
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 Lindeijer21-499/+471
* 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.
2024-02-13Removed no longer supported admin messagesThorbjørn Lindeijer8-158/+5
* Removed /announce command * Changed "Kick player" in player pop-up to kick by name Other messages, like CMSG_ADMIN_HIDE, CMSG_ADMIN_MUTE and CMSG_ADMIN_LOCAL_ANNOUNCE were already not used by the client. Also, none of this was implemented for Manaserv.
2024-02-13Reverted the PhysicsFS check for Ubuntu 18.04 compatibilityThorbjørn Lindeijer1-2/+2
Apparently, pkg-config files for physfs were not shipping yet in Ubuntu 18.04. Now it no longer checks that we have at least physfs 3.0, but older versions should be pretty rare anyway. This reverts part of ffa8ea13fbf50ad59d9fc4cea71b9aec4aca8bac.
2024-02-13Fixed music playbackThorbjørn Lindeijer2-21/+7
A faulty version check was disabling music loading entirely.
2024-02-13General code cleanupsThorbjørn Lindeijer94-663/+348
* Removing unused includes * Use member initialization * Use range-based for loops * Use nullptr * Removed no longer used aliases * Use override * Don't use else after return * Use '= delete' to remove implicit members * Use std::string::empty instead of comparing to ""
2024-02-09CI: Don't build in parallel for nowThorbjørn Lindeijer1-1/+1
2024-02-09Optimized BrowserBoxThorbjørn Lindeijer9-351/+327
* Introduced a LayoutContext that conveniently allows for relayouting all rows, or just a single one when it is added. BrowserBox::addRow no longer relayouts all the rows. * BrowserLink and LinePart are now merged into a new TextRow struct, so they can be conveniently dropped when the row limit has been reached. * Removed "opaque" option, which was enabled by default but disabled for all BrowserBox instances. * Removed "always update" option, and instead start delaying relayouting automatically when there are a lot of rows (> 100 currently). * Update window now also has text wrapping enabled. Closes #50
2024-02-09Some cleanups in UpdaterWindow and BrowserBoxThorbjørn Lindeijer4-170/+79
Doing some cleanups before working towards optimizing this code. Removed needless additional wrapping code in BrowserBox::addRow, since the text will be relayouted anyway. Simplified layouting code a little. For example, there's no need to keep track of the number of wrapped lines. Use more optimal data structures, like an std::deque for the text rows and a plain std::vector for the line parts. Both have less fragmentation than an std::list.
2024-02-09C++11: Use default member initializersThorbjørn Lindeijer53-303/+174
This patch is not exhaustive.
2024-02-07Introduce .gitlab-ci.ymlThorbjørn Lindeijer2-2/+28
This just checks that the client compiles on Ubuntu for now. Also fixed a PhysicsFS linker issue introduced in ffa8ea13fbf50ad59d9fc4cea71b9aec4aca8bac...
2024-02-07Added libpng-dev to Ubuntu dependenciesThorbjørn Lindeijer1-1/+1
It is used for writing screenshots.
2024-02-06Fixed crash when taking a screenshotThorbjørn Lindeijer1-1/+5
Wrong format was passed to SDL_RenderReadPixels. Issue introduced in 2c51c98625b225cecfb9628c30d62d4e30f7e3e1. Closes #52
2024-02-05Removed use of deprecated std::unary_functionThorbjørn Lindeijer1-9/+6