summaryrefslogtreecommitdiff
path: root/src/map/path.c
AgeCommit message (Collapse)AuthorFilesLines
2018-07-01Change functions to static where possible (Part 4 - map)Haru1-9/+10
This fixes issues with plugins defining symbols with the same names Signed-off-by: Haru <haru@dotalux.com>
2018-05-312012-2018 !Maytichai Saowa1-1/+1
2016-10-28Fixed copyright year for 2016Lemongrass31101-1/+1
2016-10-07Fixed some issues detected by clang's static analyzer (Xcode 8/macOS Sierra)Haru1-2/+0
Signed-off-by: Haru <haru@dotalux.com>
2016-06-25Fix assert checks from commit e28a19cfff1f26457d6a0f6192d6782c8db7d3d2.Andrei Karas1-3/+3
2016-06-24Add missing checks into path.cAndrei Karas1-0/+5
2016-05-08Fixed various issues pointed out by cppcheckHaru1-4/+4
Signed-off-by: Haru <haru@dotalux.com>
2015-12-15Added GPL-compliant header to all sources and build scriptsHaru1-4/+20
Signed-off-by: Haru <haru@dotalux.com>
2015-10-19rename malloc.c/h to memmgr.Andrei Karas1-1/+1
2015-10-11Changed VECTOR/BHEAP/ARRAY macros to discourage usage of unsigned loop counters.Haru1-1/+1
Signed-off-by: Haru <haru@dotalux.com>
2015-09-25More aggressive whitespace cleanup. Follow up to 51329e6Haru1-3/+2
Signed-off-by: Haru <haru@dotalux.com>
2015-09-24Add bl parameter to getcell functions.Andrei Karas1-13/+13
2015-09-10Add to path search functions source bl for plugins usage.Andrei Karas1-3/+3
2015-08-15HPM compatibility improvementsHaru1-0/+1
Improved compatibility, portability and standards conformance. - Since it is not possible to portably and reliably re-use the core's symbols in plugins, symbols are no longer exported unless explicitly required, in the UNIX builds. This mimics the Windows behavior and adds HPM compatibility to OSes such as FreeBSD. Credits to Andrei Karas for making this possible. - For convenience, it is no longer necessary to call GET_SYMBOL, since the plugin will automatically import all the available symbols when it's loaded, depending on the included headers. - Plugins are now supposed to include the "common/hercules.h" header before including anything else. Incluing common/HPMi.h, common/cbasetypes.h or conf/core.h is no longer necessary, as those are guaranteed to be automatically included by hercules.h. - HPM API version bumped to 1.1. Signed-off-by: Haru <haru@dotalux.com>
2015-06-19Removed ".." from include directivesHaru1-10/+10
- Include directives are now directory-independent. - This will allow building plugins from other directories in future. Signed-off-by: Haru <haru@dotalux.com>
2015-01-17Another ~10 Fixesshennetsind1-0/+6
Addressing out of bounds read/write. Special Thanks to 4144 and Haruna! Signed-off-by: shennetsind <ind@henn.et>
2014-11-16Whitespace cleanup (no code changes)Haru1-2/+2
This includes, and is not limited to: mixed or wrong indentation, excess whitespace (horizontal and vertical), misalignment, trailing spaces. Signed-off-by: Haru <haru@dotalux.com>
2014-11-03* No cell stacking implemented (official version)Michieru1-4/+0
- Split config cell_stack_limit into custom_cell_stack_limit (previous feature) and official_cell_stack_limit (see below) - Expanded map_count_oncell by a flag parameter, currently only one flag is supported: only count standing units (needed for official cell stack feature) - Added a new function map_closest_freecell that will return the closest free cell using the same order that official servers use - Monsters will now actively search for a free cell when starting to walk randomly and when unlocking target - When any unit finishes walking (regularly) and is not on a free cell, it will now actively search for a free cell - Step actions will be delayed until a suitable cell was found, they will even be executed when the player walked slightly out of attack range - Monsters will now stop instantly if their target is completely non-existent * This is mainly for looters that had their loot taken * Hide and most other situations still use the configuration setting monster_chase_refresh Mega Thanks to Playtester
2014-10-18Fix bug:7454Michieru1-5/+2
* Official Icewall implementation and other fixes - Reverted all the icewall-related changes done in SVN r15777 and following as testing shows they aren't official and are actually pretty exploitable (bugreport:7412) - Instead implemented the official icewall characteristic that monsters can only leave an icewall cell to the west or south, the changes include: * The "sight" path check no longer checks for the current cell so standing on an icewall allows you to see/attack into any direction * The path finding will still ignore the current cell as before but the walk routine will not allow to walk east or north while standing on an icewall cell * This leads monsters in the situation where they go through an AI loop not allowing them to escape the icewall (if their target is north or east of them) * Monster in this situation will use idle skills and if they get attacked will use their rudeattacked skills if available, similar to traps like Spiderweb * Added a configuration icewall_walk_block that allows to configure how long a monster should go through the AI loop before the server allows it any movement, this "safety" system is official and seems to equal about 75 AI loops; if you want to disable the whole icewall system so that monsters don't get stuck in icewall at all, just set this to 0 * Here are videos from jRO showing how this system works: http://ragdo.blog56.fc2.com/blog-entry-763.html - Implemented the official calculation for "direction"; now you will be considered horizontal/vertical/diagonally aligned with a target cell in the exact same way as on official servers, this is for example used to determine whether an icewall or a firewall should be horizontal, vertical or diagonal; the only thing that is still unofficial is the default direction (officially always "west"); effectively now there are more situations considered diagonal than before - Further cleanups on the idle skill use code for immobile monsters and monsters near a player but without a target (now skill using will always go via mob_unlocktarget) * This also fixes that monsters switched to idle mode and start to use idle skills one second too late Mega thanks to Playtester (rathena 5540d89cb0e)
2014-10-13* Monster skill use behavior, ranges, position lag fixesMichieru1-1/+40
- Updated monster skill use behavior so monsters use skills the same way and at the same rhythm as official servers (bugreport:009326), the changes include: * Unified the "monster can't move by default" and the "monster trapped" code as it really should behave exactly the same * Fixed a bug that caused the "monster skill use" routine to be called 20 times more often than it should in some situations * When a monster attacks you and you run away from it, the monster will now check if it has a ranged skill on "attack" state before switching to chase state * Monsters will now always do a normal attack before using "attack" state skills * Fixed a bug that caused monsters to switch to idle mode and never use their chase skills when they get hit continuously * Changed default for skillrange_from_weapon from 30 (all but player) to 0 (none); monsters will now use all skills at the skill range and not at their own attack range, if they get tanked from farther away than skill range, they won't use these skills - Updated ranges to work as on official servers (bugreport:009326), the changes include: * Implemented new functions "check_distance_client" and "distance_client", that instead of the server-sided square range system use the circular one that the client uses; these functions should be used for units that send their commands via the client (players mostly) * Applied the new distance algorithm to some player-specific range checks, players will now have a circular attack range that reflects their attack range on the client; this makes it impossible to hack the client for more diagonal range * Removed the arbitrary +1 range bonus at range checks; as monsters now react fluently, they won't need it anymore, that means a monster with for example 4 attack range will now only attack targets within a 9x9 area around it, the moment you step out of this area, the attacks will stop (if the monster can move it will follow you); as for players, the extra cell attack range when on a linear line to the target now is integrated into the distance algorithm, that means a player with attack range 4 can attack from 5 cells away when directly on line with a monster, but no longer diagonally as range is circular for players now * Implemented a new "step action" feature to reflect official chase range behavior; when an attack or skill is used inside the attack range, it will act exactly as now, the skill is used once the signal from the client was received; however, if an attack or skill is used outside the attack range, the player should move into the chase area which is 1 cell inside the attack range border; the client actually sends us where to use the attack / skill from, but previously we just dropped that information the moment an attack request came; now instead of stopping the player instantly on an attack request, the player will continue moving to the target cell and then automatically use the command received earlier (it will be remembered); this change was absolutely necessary as the client sends the attack request slightly before attack range is reached, execution on official servers only takes place on every full cell moved; the new system copies this behavior - Implemented an improved hit-lock system (bugreport:007460), the changes include: * MVPs are no longer immune to being stopped by a hit unless they used Endure * When hitting any unit, it will stop for its "dMotion" interval, exactly at the end of "dMotion" it will continue walking (official behavior); this helps getting more "move" packets to be displayed * The unit that was hit will be immune to being stopped for another "dMotion" interval, this allows to slow down any units by hitting them frequently, but makes it almost impossible to completely stop them forever (depends a lot of ASPD and dMotion value); this does not affect special hit-lock properties (some skills and events should set delay anyway) * The unit that was hit will no longer be "pulled" to the next cell; this caused a lot of position lag, it should be much better now * Random walking, monster target dropping - Implemented official behavior for random walking of monsters (bugreport:9340) * Updated the interval between walks from 3-6 seconds to 4-5 seconds * Added a define MIN_RANDOMWALKTIME that is now used anywhere the interval is applied so it's easier to change * Monsters will no longer attempt to walk to the cell they are currently standing on (note: still requires a proper "no cell stacking" implementation) * Monsters will only target a cell within a 15x15 area around them - Moved the "mob_ai" 0x008 configuration setting to mob_unlocktarget, so it applies to all cases of monsters unlocking targets - Cleaned up the unit_stop_attack and unit_stop_stepaction functions * unit_stop_attack now makes sure that the target is always set to 0, even if no attack timer currently exists * replaced several calls of unit_set_target that set target to 0 with unit_stop_attack, this is important because the attack timer should always be deleted at the same time the target is set to 0 * this also fixes the problem that caused monsters to sometimes drop their target after an attack * Minor monster walk and skill use fixes - Fixed a bug that caused monsters to never use their idle skills even if the define MOB_LAZYSKILLPERC was set * The default value of the define is now 100% for spotted mobs and 0% for non-spotted mobs as on official servers - Monsters now use complex path searching for their random walk, so they can also walk around corners now (OFFICIAL_WALKPATH still applies!) - Fixed spotted monsters using their "walk" skills even if nobody is on the map - Monsters will no longer stop when using "walk" skills (they are supposed to be used while walking) * Monster idle skills, chase, final cleanups - Spotted monsters will now use their idle skills even if no players are on the map * This is official behavior and allows them to metamorph and heal up even if nobody is on the map * I originally had concerns about the performance, but as the dynamic mobs option is enabled by default and set to 5 minutes, monsters will only stay "spotted" for 5 minutes when nobody is on the map anyway, this doesn't cost much extra performance - Increased chase range of monsters by 2 * Tested this thoroughly and the effective chase range is actually 2 cells larger than listed in the "Range3" column * Special thanks to ultramage and Michieru for helping me testing this - Some final cleanups in the unit_stop_attack and unit_stop_stepaction functions * Special thanks to icxbb-xx for pointing these out Super ultra mega thanks to Playtester (rAthena 2c86ee435670168,ebd3dc97bc7e,f3916c1baf1,b1330a4c6,c2377c8f54,464dd4586380)
2014-10-04Pathfinding now works exactly as on the clientMichieru1-23/+20
- This should solve most of the position lag problems, especially ones that caused monsters to suddenly appear next to you (happened especially often when using icewall) - Added a new heap implementation to db.h (POP2, PUSH2, SIFTUP, SIFTDOWN, UPDATE) that simulates the heap that the client uses, there was no other way to reproduce 100% exact behavior - I recommend using the old heap implementation for everything else - Updated path.c to use the new heap macros and also fixed the order in which the different possible directions are pushed into heap - Special thanks to rversteegen for helping me with various tests and the heap implementation - Special thanks to ultramage for providing info that helped us narrowing down the possible variables Mega thanks to Playtester (rathena:c009b3f4a)
2014-08-10HPM Hooks UpdateHercules.ws1-2/+2
Signed-off-by: HerculesWSAPI <Hercules@efficiently.awesome>
2014-08-10- Fix makes knockback default to the leftMichieru1-4/+3
- Fix Back Sliding should not have animation
2014-05-13Removed trailing whitespace (sources)Haru1-2/+2
Signed-off-by: Haru <haru@dotalux.com>
2014-05-10Re-commit of "Fixed order of includes in all source files"Haru1-7/+10
This reverts commit 94657284973f4037596bae468ebfbee5c217e02b.
2014-05-10Revert "Fixed order of includes in all source files"panikon1-10/+7
This reverts commit b6b3f58795288701d0e162d43fa6f0a47af913b3. Fixes issue 8184 http://hercules.ws/board/tracker/issue-8184-cart-related/
2014-05-09Fixed order of includes in all source filesHaru1-7/+10
- Changed order according to the (upcoming) code style guidelines. - Fixes several issues caused by missing headers when their include order is changed or in plugins. Signed-off-by: Haru <haru@dotalux.com>
2014-03-23HPM Hooks UpdateHercules.ws1-11/+11
Signed-off-by: HerculesWSAPI <Hercules@efficiently.awesome>
2014-03-23Fix Bug 8106Michieru1-23/+11
http://hercules.ws/board/tracker/issue-8106-crescent-elbow-knockback-range/ Increase reflect damage make by crescent elbow Fix Bug 8099 http://hercules.ws/board/tracker/issue-8099-renewal-acid-bomb-damage/ Cart Revolution will now always knock targets to the West - rAthena:1f26499994af9b64aa96d5ed46f6e7cdefdb025b Fix a bug with Backslide that let you continue to move even if you hit a wall on some case. Thanks to Ind
2013-12-17Fixed several compiler warningsHaru1-0/+2
- Warnings detected thanks to Xcode's compiler settings (more strict by default) and clang, warnings mostly but not only related to data sizes on 64 bit systems, that were silenced until now by very lax compiler settings. - This also decreases by a great deal the amount of warnings produced by MSVC in x64 mode (for the adventurous ones who tried that) - Also fixed (or silenced in case of false positives) the potential issues pointed out by the (awesome) clang static analyzer. - Patch co-produced with Ind, I'm merging and committing in his place! Signed-off-by: Haru <haru@dotalux.com>
2013-10-02HPM: Map.c Completedshennetsind1-6/+6
Fully Interfaced. Moved missing vars and declarations of interest into the interface, removed duplicate mentions of map within calls to shorten wherever it made sense to. Ladies and Gentleman its my pleasure to announce that with this commit we've revised all of map-server, we've learned a hell lot from this, improved many things on the go and have a number of features to be released thanks to this. *cough* hpm hooking *cough*. Signed-off-by: shennetsind <ind@henn.et>
2013-09-26Renamed variables that would conflict with a rename of iMap to mapHaru1-6/+6
Note to plugin developers: if you were importing the "map", you'll need to change it to "maplist" Signed-off-by: Haru <haru@dotalux.com>
2013-09-16HPM: Path.c Interfaceshennetsind1-2/+14
Fully Integrated Signed-off-by: shennetsind <ind@henn.et>
2013-07-23Pathfinding code cleanup.Piotr Hałaczkiewicz1-244/+242
Now uses binary heap defined in `db.h`. Walk requests now use A* (hard) pathfinding only to match game client behavior. Added defines for movement cost. Added some documentation & comments.
2013-06-08Follow up d73783f22b2bb881aab74524d153d89a5932a199shennetsind1-1/+1
Adjusting pc.c interface name to adhere with the rest (pretty much we try to make it as short as we can, and being there were no conflicts we saw no reason to maintain the 'i') Signed-off-by: shennetsind <ind@henn.et>
2013-05-30Memory Slasher - May 30 Patchshennetsind1-19/+17
http://hercules.ws/board/topic/928-memory-slasher-may-30-patch/ Signed-off-by: shennetsind <ind@henn.et>
2012-12-30-Harmonize skillid, skill_num, skillnum, skill, to skill_id and same for ↵glighta1-13/+13
skill_lv -Optimise type from int to int16 in order to reduce ram consumtion. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@17065 54d463be-8e91-2dee-dedb-b68131a5f0ec
2012-12-05- Undid r16968: SVN Replaced with source:/trunk/src/@16966 (tid:74924).brianluau1-340/+346
[16969:16991/trunk/src/] will be re-committed in the next 24 hours. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@16992 54d463be-8e91-2dee-dedb-b68131a5f0ec
2012-11-25Applied AStyle code formating as discussed on tid:74602.greenboxal21-346/+340
Removed /SAFESEH option from MSVC11 projects. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@16968 54d463be-8e91-2dee-dedb-b68131a5f0ec
2012-10-29* Follow-up r16835: Some cleanup.euphyy1-1/+1
* Updated Hunting Missions script to v1.2b, which adds experience multipliers to config (custom\quests\hunting_missions.txt) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@16839 54d463be-8e91-2dee-dedb-b68131a5f0ec
2012-10-29-Add some src basic documentation.glighta1-8/+7
-Change some remaining -1 for status ending timer. -Move some hardcoded msg in msg_athena -Small optimisation on battle_attr_fix git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@16835 54d463be-8e91-2dee-dedb-b68131a5f0ec
2012-01-17Enabled Mersenne Twister MT19937 as random number generator instead of ↵gepard19841-1/+2
standard `rand()` function (follow-up to r14865, r14870). - It fixes issues caused by RAND_MAX being only 32k in Windows system (bugreport:1927, bugreport:86). git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@15483 54d463be-8e91-2dee-dedb-b68131a5f0ec
2010-12-22* Resolved random compiler warnings.ai4rei1-1/+1
- Silenced pointer size mismatch gcc warning for variables passed to script_setarray_pc (bugreport:4661, since r14613). git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14615 54d463be-8e91-2dee-dedb-b68131a5f0ec
2008-01-04Fixed a mistake in r11991 that let knockback work through wallsultramage1-2/+2
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12010 54d463be-8e91-2dee-dedb-b68131a5f0ec
2008-01-04Modified the map_setcell() code to to use a boolean flag instead of needing ↵ultramage1-2/+2
SET_ / CLR_ pairs of defines (topic:174323). Also removed script object 'setcell', added script function 'setcell'. - Now you can manipulate cell information without needing @loadnpc - You can also manipulate the terrain ('gat') type itself, using the new cell_walkable, cell_shootable and cell_water constants (currently the implementation uses bit flags too, so to get the type you want, you need to adjust the flags one by one) - This breaks current scripts, so please adjust places that use setcell (also be sure to _only_ use predefined constants, not direct numbers) - Details can be found in the script reference. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12009 54d463be-8e91-2dee-dedb-b68131a5f0ec
2008-01-03Map cell mechanism rewriteultramage1-3/+3
- defined a data structure for map cells (replaces 3 various cell arrays) - both terrain (gat) and dynamic (cell) information is now stored as C-style bit flags instead of #defines and bitmasks - added map_gat2cell() and map_cell2gat() for terrain type conversions - changing terrain information via 'setcell' is temporarily disabled - mapserver startup now takes longer, as it needs to adapt mapcache data to internal representation, cell by cell (new mapcache format anyone?) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12003 54d463be-8e91-2dee-dedb-b68131a5f0ec
2007-12-29Knockback now works through cells where there is a diagonal path, but no ↵ultramage1-56/+22
horizontal+vertical alternative (like two perpendicular icewalls with a gap where they 'join'). Some dead code removal in path.c. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11991 54d463be-8e91-2dee-dedb-b68131a5f0ec
2007-12-26Moved distance-related functions to path.c/hultramage1-0/+43
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11981 54d463be-8e91-2dee-dedb-b68131a5f0ec
2007-12-22Path code cleaning...ultramage1-91/+84
* Added map/path.h, moved path-related function headers to path.h. * Removed the macroed _real() path functions. * Modified some functions to use boolean return values instead of 1/0 or 0/-1. * Modified path_search_long() to allow a NULL output pointer (in which case a temporary local buffer will be used instead). * Removed an unused ->path_half member variable from struct walkpath_data. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11958 54d463be-8e91-2dee-dedb-b68131a5f0ec
2007-11-19* Nullpo's disabled on release builds.FlavioJS1-4/+0
* Added timestamps to the log of memory leaks. * Moved definition of __func__ to cbasetypes.h. * Configure script updated: - added option to select the memory manager - added option to enable MAPREGSQL - added option to enable DEBUG * common's Makefile deleting svnversion.h on 'clean' target. (run ./configure again to update your Makefile) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11760 54d463be-8e91-2dee-dedb-b68131a5f0ec