summaryrefslogtreecommitdiff
path: root/src/game.cpp
AgeCommit message (Collapse)AuthorFilesLines
2024-10-29Turned the PlayerRelation struct into an enum classThorbjørn Lindeijer1-3/+3
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 Lindeijer1-5/+6
Seems to be no point in using a macro here.
2024-10-23Various small fixes to translatable stringsThorbjørn Lindeijer1-4/+1
Mostly adjustments based on feedback from the Finnish translator.
2024-10-18Avoid accessing static members through instancesThorbjørn Lindeijer1-30/+30
Fixed with clang-tidy `readability-static-accessed-through-instance` check.
2024-10-15Fixed crash when taking screenshot with scaled graphicsThorbjørn Lindeijer1-9/+14
Because the allocated surface was based on the unscaled size, writing the actual pixels was overwriting random memory.
2024-10-08Do a single logic update each frameThorbjørn Lindeijer1-3/+11
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-2/+0
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-04-02General code cleanupsThorbjørn Lindeijer1-5/+3
* 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-22Added support for scaling the outputThorbjørn Lindeijer1-1/+2
* Added "Scale" user option, which can either by "Auto" or an explicit scaling factor. Its maximum value depends on the current resolution. The "Auto" factor is based on keeping the logical resolution on at least 800x600, wheres the maximum scale is based on keeping the logical resolution on at least 640x480. * Enabled support for High DPI. This means the rendering target can now have a different resolution than the window size, which can happen on macOS, Windows and Wayland. The resulting scale is multiplied by the above user-controlled scale. Currently, this looks ugly for non-integer scales, which are not used on macOS and can only be configured on some Wayland compositors. Has not been tested on Windows. * Simplified OpenGL initialization (moved out of _beginDraw). * Made sure _beginDraw/_endDraw sets a clip area also for SDLGraphics.
2024-03-12General code cleanupsThorbjørn Lindeijer1-13/+11
* 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-02-27Added VSync and windowed fullscreen optionsThorbjørn Lindeijer1-2/+2
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 Lindeijer1-3/+3
* 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 Lindeijer1-1/+1
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-01-26Apply C++11 fixitsThorbjørn Lindeijer1-21/+21
modernize-use-auto modernize-use-nullptr modernize-use-override modernize-use-using
2024-01-25Minor includes cleanupThorbjørn Lindeijer1-2/+0
2024-01-25Ported to SDL2Thorbjørn Lindeijer1-2/+2
2012-02-09Allow changing fullscreen resolution without restartThorbjørn Lindeijer1-1/+1
Unified Graphics:setFullscreen and Graphics:resize into a single Graphics:changeVideoMode function that tries to restore the existing mode when changing to the new mode didn't work, and exists with an error when that also fails. Split up handling of SDL_VIDEORESIZE and the adapting to new resolution in the Client class, so that the second part could also be called when changing resolution fullscreen mode. The Video tab in the Setup window now also filters out any modes smaller than 640x480 since the game won't properly adapt to that resolution anyway. Reviewed-by: Yohann Ferreira
2012-01-26Updated copyrights to 2012Thorbjørn Lindeijer1-1/+1
2012-01-22Prevented looking at item when picking up while movingErik Schilling1-22/+4
+ Fixes from Bjorns review. Reviewed-by: Bjorn.
2012-01-22Allow resizing of the game in windowed modeThorbjørn Lindeijer1-3/+13
Window positions are semi-smartly corrected as a result of the resize. Not supported when using OpenGL on Windows for now. Reviewed-by: Yohann Ferreira
2012-01-16Renamed some file names for consistency with the class namesThorbjørn Lindeijer1-4/+4
This was already done by ManaPlus. It's a good idea anyway and it makes comparing the code a little easier. Reviewed-by: Yohann Ferreira
2012-01-14Don't lose the active target when pushing the target&attack key while moving.Yohann Ferreira1-2/+2
1st part of Mana-Mantis #441. Reviewed-by: Bjorn
2012-01-10player_node -> local_playerYohann Ferreira1-31/+31
Reviewed-by: Ablu
2012-01-09Added a close button to the npc dialog window.Yohann Ferreira1-2/+12
The close button will only display when the window is waiting for the server, so that crashed windows can be closed without restarting the client. Pushing the QUIT key (Escape by default) will also close the crashed windows in that case. I also fixed a memleak with the "next" button. Resolves: Mana-Mantis #72, 93, 389. Reviewed-by: Ablu.
2011-08-19Merge git://gitorious.org/~bertram/mana/mana-equipment-fix into equipment-fixYohann Ferreira1-9/+1
2011-08-18Made the equipment window not use server specific code again.Yohann Ferreira1-9/+1
I also made the number of slots displayed taken from the equip.xml file for manaserv.
2011-08-11The shortcuts are now refreshed when reassigning keys.Yohann Ferreira1-1/+0
2011-06-17First pass on removing tile hard coded values.Yohann Ferreira1-0/+16
Every files has been checked against the hard coded 32 values except the map.cpp file. I also added convenience functions in the Game class, centralized the default item icon size, and removed two unused defines in being.cpp.
2011-06-16Remove useless ping packetBen Longbons1-11/+0
The comment in game.cpp about the server waiting for this is a lie. Reviewed-by: Bertram.
2011-06-02Some work on the manaserv equipment backendThorbjørn Lindeijer1-7/+5
Currently the same equipment window is used as for tmwAthena so that at least something is visible. This means the location of equipped items is currently illogical. It is now possible to equip and unequip items. Mantis-issue: 164 Reviewed-by: Stefan Dombrowski
2011-05-20Removing KEY_PATHFIND and moving its function into the debug windowStefan Dombrowski1-5/+0
* The f-key is no longer used. That means new players are less likely to get into trouble by accidentally activating the debug mode. * The debug mode can now be activated in a new tab in the debug window. * The main advantage of using a gui is its extensibility. At the moment the debug mode does show too much information at once. In a follow-up patch the user should get more choices. Reviewed-by: Bjorn
2011-04-30Fixed disconnected dialog to only pop up onceThorbjørn Lindeijer1-2/+4
Bug introduced in 88934303761ba950be56eac8b60de2dede88a29f and spotted by Stefan Dombrowski. Reviewed-by: Stefan Dombrowski Reviewed-by: Yohann Ferreira
2011-04-26Made the client use a unique kind of movement code.Yohann Ferreira1-26/+35
This is fixng many issues and (hopefully) will make the movement rendering much smoother. Merge branch 'master' of gitorious.org:~bertram/mana/mana-movement-code-merge Conflicts: src/being.cpp src/net/manaserv/beinghandler.cpp Resolves: TMW-Mantis #946. Reviewed-by: Thorbjorn.
2011-04-18A bit of cleanup in the way the Client pops up error dialogsThorbjørn Lindeijer1-11/+3
No point in using mCurrentDialog for the OkDialog, since it will clean up after itself, as was pointed out in many places throughout the code. Now there are two convenience functions for popping up the OkDialog and having it change to a specified state afterwards. This also gets rid of the 4 different ActionListener classes that existed solely for this purpose. Reviewed-by: Yohann Ferreira
2011-04-16Introduced the Being::lookAt() function.Yohann Ferreira1-36/+35
We're now using it when picking up items. Also, de-overnested the Game::handleInput() function when handling pickups.
2011-04-11Implemented a simple non-blocking fadeOutAndPlay system.Yohann Ferreira1-2/+2
It's currently used when changing maps. Resolves: TMW-Mantis: #750. Reviewed-by: Thorbjorn.
2011-04-09Removed the Mana namespaceThorbjørn Lindeijer1-12/+12
It's just an annoyance when it's only applied to a few classes. Either we place everything in this namespace or nothing, and at the moment I don't see any rationale for placing everything in a Mana namespace. Acked-by: Jared Adams
2011-04-09Moved Channels to Mana::Event::ChannelThorbjørn Lindeijer1-11/+11
Acked-by: Jared Adams
2011-04-09Moved Events to Mana::Event::TypeThorbjørn Lindeijer1-11/+11
Acked-by: Jared Adams
2011-03-26Add search bar to storage and inventory windowsBlue Sans Douze1-1/+1
Reviewed-by: thorbjorn
2011-03-17Fixed pick up using keyboard for both servers.Yohann Ferreira1-20/+30
The character picks up one item at a time (to remain kinda realistic) and turns to the item picked up.
2011-02-01Merge branch '0.5'Thorbjørn Lindeijer1-3/+3
Conflicts: po/de.po src/game.cpp src/resources/wallpaper.cpp
2011-01-25Added a child class to the equipment window specialized for tAthena.Yohann Ferreira1-1/+11
(As requested by Thorbjorn.) Now the foundation to set up per-protocol equipment display is ready.
2011-01-22Fixing pick-up with joystickStefan Dombrowski1-3/+3
The pick-up with the joystick happend on the wrong tile. Bug was reported by Feufochmar on IRC.
2010-12-15Merge branch '0.5'Thorbjørn Lindeijer1-1/+2
2010-12-06Removed superfluous #includes taken from checkheaders list.Yohann Ferreira1-1/+0
Resolves: Mana-Mantis #265. Trivial fix.
2010-11-29Allow enter OK button key in input field.Andrei Karas1-1/+2
By default OK shortcut is space key. Reviewed-by: Jaxad0127, Kage
2010-11-11Replace Event names with enums instead of stringsChuck Miller1-11/+11
2010-11-11Have the event system channels use enums instead of stringsChuck Miller1-11/+11
Reviewed-by: Freeyorp
2010-11-01Merge branch '0.5' of gitorious.org:mana/manaYohann Ferreira1-9/+21
Conflicts: src/being.cpp src/client.cpp src/commandhandler.cpp src/gui/setup_video.cpp src/gui/socialwindow.cpp src/gui/viewport.cpp src/gui/widgets/browserbox.cpp src/gui/widgets/itemcontainer.cpp src/imageparticle.cpp src/localplayer.cpp src/localplayer.h src/map.cpp src/net/tmwa/beinghandler.cpp src/particle.cpp src/particle.h src/player.cpp src/player.h