AlexVinS
3216422307
Fixed a few CWE-457
2016-11-27 22:07:01 +03:00
Vadim Markovtsev
2c1dddde33
Fix memory problems with BonusList
...
Bonus * -> std::shared_ptr<Bonus>
This cures the following problems:
1) Memory corruption at exit. Some Bonus-es were deleted twice (mods?).
2) Memory leaks. Some Bonuses were not deleted.
3) Reduce the number of "Orphaned child" messages.
Valgrind reports 0 leaked memory now and no invalid reads/writes.
2016-09-29 15:08:00 +02:00
Arseniy Shestakov
b0045fa357
Fix TurnInfo memory leaks
2016-08-16 15:47:21 +03:00
Arseniy Shestakov
b4a35f9c62
CPathfinderHelper: fix memory leak
2016-08-16 14:59:16 +03:00
Arseniy Shestakov
30189a386f
CPathfinder: fix and improve sail-land transition checks
2016-02-26 21:43:43 +03:00
AlexVinS
6e205a58b4
Merge remote-tracking branch 'remotes/origin/develop' into feature/VCMIMapFormat1
...
Conflicts:
lib/VCMI_lib.cbp
lib/filesystem/CZipLoader.cpp
lib/filesystem/CZipLoader.h
lib/mapObjects/CGTownInstance.cpp
2016-02-04 10:27:51 +03:00
Vadim Markovtsev
3926920103
Rename radious -> radius
...
There is no such English word, "radious"
Some files get new lines in the end - BSD sed bug + best practices
2016-01-31 18:01:58 +03:00
AlexVinS
37d0dad70a
Merge branch 'develop' into feature/VCMIMapFormat1
...
Conflicts:
lib/CArtHandler.cpp
2016-01-01 20:28:52 +03:00
ArseniyShestakov
9490a5d66d
CPathfinder: deny transit to land blockvis objs from water layer
...
When hero is in water walking layer he can only exit to accessible or visitable land tiles, but not objects that have blocking visit and leave hero standing on water.
This is different than default flying behaviour because hero in air layer can only transit into accessible land layer without any blocking or visitable objects on them.
2015-12-16 20:14:36 +03:00
ArseniyShestakov
bf9ac7318a
CPathfinder: change cost calculation sequence for embark / disembark
...
With old embark cost calculation pathfinder may end up thinking that hero can embark/disembark while have less movement points than base movement cost is. Now hero would be only able to embark / disembark if we have enough movement points to step on that tile. This rule is also valid for situation when hero have Admiral's Hat as in H3 even if hero don't have embark penalty he still use move points for embark and disembark.
Problem was found as it's was causing infitite loop in AI. Server of course rejected attempt to embark with less than 100 movement points while pathfinder tell AI that it's can still embark with 93 movement points.
2015-12-15 20:08:52 +03:00
ArseniyShestakov
2724a67a27
CPathfinder: add border gate support and use passableFor
2015-12-14 14:33:50 +03:00
ArseniyShestakov
ab92123da3
CPathfinder: improve support for visits and battles in teleports
...
Related movement code for client and AI is plumbed as well. Though at moment code still not finished because it's not teleport hero to the exit tile if he won battle.
2015-12-11 09:42:30 +03:00
ArseniyShestakov
a430769b44
CPathfinder: fix possible crash when using invisible teleport exit
...
This one is similar with FoW bug when hero was covered by FoW while one tile around wasn't.
2015-12-11 04:10:30 +03:00
ArseniyShestakov
c3e5231146
CPathfinder: avoid pathing through hero standing on Subterranean Gate
...
Subterranean Gates unlike Monolith allow to visit hero standing on other exit. So of course pathfinder allowed that, but it's also allowed future movement through that hero which caused infinite loop for AI.
2015-12-10 16:51:19 +03:00
ArseniyShestakov
05a34fb417
Use "Favorable" instead of "Favourable" everywhere for consistency
...
Original game of course used american english version so we stick to it.
2015-12-06 02:23:41 +03:00
AlexVinS
947edc0693
Merge branch 'develop' into feature/VCMIMapFormat1
2015-12-05 13:04:04 +03:00
AlexVinS
6552acdff6
Check coastal tile OTF
2015-12-05 12:36:29 +03:00
ArseniyShestakov
9e7e5b81e4
Merge pull request #143 from vcmi/feature/patrolSupport
...
Patrol support for AI heroes
2015-12-05 03:11:07 +03:00
ArseniyShestakov
82ce58eceb
CPathfinder::initializePatrol: don't pass valid PlayerColor
...
It's break getTilesInRange with mode 0 and we don't really need to check visibility anyway.
2015-12-05 01:45:10 +03:00
ArseniyShestakov
bdc369ffba
Patrol: use manhattan distance for getting tiles in radius
2015-12-04 21:08:09 +03:00
Ivan Savenko
7b5a7f43ad
Removed includes of CGameState from headers
2015-12-02 21:39:53 +02:00
ArseniyShestakov
6bb205b15b
CPathfinder: patrol support using getTilesInRange
...
For now we use getTilesInRange which isn't really correct for patrol, but good enough for first version.
2015-11-28 20:34:50 +03:00
ArseniyShestakov
df4515901d
CPathfinder: fix special movement boundary check
...
Forgot to fix it for water walking after fe12b8f664
2015-11-23 14:11:08 +03:00
ArseniyShestakov
f4c06660e4
CPathfinder::evaluateAccessibility: apply more optimizations
2015-11-22 21:31:47 +03:00
ArseniyShestakov
2632389aaf
CPathfinder: bring FoW reference back to avoid performance loss
...
This one is revert 148355908d
2015-11-22 21:06:37 +03:00
ArseniyShestakov
6dacb84404
CPathfinder::addNeighbours: avoid allocating new vector each time
2015-11-22 07:32:33 +03:00
ArseniyShestakov
5a87f58e09
CPathfinder: optimize checks order in calculatePaths
2015-11-22 06:23:54 +03:00
ArseniyShestakov
8217eb3a82
CPathfinder: split isLayerTransitionPossible into two functions
...
This way we can avoid usage of getNode for layers that clearly can't be used.
2015-11-22 06:16:16 +03:00
ArseniyShestakov
a1fe2ebc44
Pathfinding: restore gamestate usage to avoid overhead
...
Also when possible pass TerrainTile pointers to getMovementCost instead of using getTile.
2015-11-21 14:31:30 +03:00
ArseniyShestakov
438a444443
CGHeroInstance: move native terrain check into getNativeTerrain
...
That make it easier to use that code independently in TurnInfo
2015-11-21 13:32:45 +03:00
ArseniyShestakov
5ae6225ebc
TurnInfo: implement internal bonus cache for most used bonuses
...
Bonus system even with caching add too big overhead so we'll only use it once for these bonuses.
Still I'm like it to be transparent for external code so it's a bit hacky code.
2015-11-21 10:00:09 +03:00
ArseniyShestakov
e91d79414b
PathfinderOptions: use settings and move all defaults into schema
2015-11-21 00:32:23 +03:00
ArseniyShestakov
cb61572878
TurnInfo: add cache for bonuses selection
2015-11-20 12:28:35 +03:00
ArseniyShestakov
7101083a24
CPathfinder: restore transit via garrisons
2015-11-18 00:07:25 +03:00
ArseniyShestakov
ab9680a7d9
CPathfinder: handle event object properly everywhere
...
Also add forgoted check for AdvmapInterface to avoid possible crash.
2015-11-17 07:09:01 +03:00
ArseniyShestakov
fe12b8f664
Pathfinding: re-introduce EAccessibility::FLYABLE
...
That let us get rid of really hacky code in initializeGraph and also fix flying over tiles that aren't visible.
2015-11-17 03:59:02 +03:00
ArseniyShestakov
c2ba3e3faf
CPathfinderHelper: very firts pass over getNeighbours
2015-11-17 02:41:31 +03:00
ArseniyShestakov
73d8687785
CPathfinder: add some comments and TODO for future changes
2015-11-17 01:38:13 +03:00
ArseniyShestakov
578aa2acd4
Pathfinding: don't use gamestate directly as it's not needed
2015-11-16 21:22:11 +03:00
ArseniyShestakov
d524b4eabe
CPathfinder: get rid of addNeighbours coord argument
2015-11-16 19:54:17 +03:00
ArseniyShestakov
8f72d73241
CPathfinder: update teleport code and use TurnInfo for whirlpools
2015-11-16 19:14:18 +03:00
ArseniyShestakov
0949283cb9
Pathfinding: pass PathfinderOptions to helper and avoid changing them
...
Original idea behind options is that options should only be set on pathfinder object creation (or via some special method in case pathfinder become persistent).
2015-11-16 18:43:02 +03:00
ArseniyShestakov
3185b64fb0
CPathfinder: rename cObj and dObjt to ctObj and dtObj
...
This way it's more clear that it's pointer to object on tile and not path node.
It's important because air layer nodes don't have visitable objects while tile under them can have one.
2015-11-16 17:41:23 +03:00
ArseniyShestakov
6dd9572644
CPathfinder: cleanup checks for source node visitable object
2015-11-16 17:36:58 +03:00
ArseniyShestakov
aa59ad05ed
CPathfinder: don't access map->guardingCreaturePositions directly
2015-11-13 23:32:52 +03:00
ArseniyShestakov
324cf5490c
CPathfinder: fix movement into guardian tile
2015-11-13 23:07:56 +03:00
ArseniyShestakov
0be9d21132
CPathfinder: add rule that hero in boat can't visit empty boats
2015-11-13 10:28:44 +03:00
ArseniyShestakov
d2baa5b0d0
Pathfinding: move isLayerAvailable into TurnInfo
2015-11-12 14:40:56 +03:00
ArseniyShestakov
abc4ea272f
TurnInfo: store all bonuses and use TileInfo for everything
...
Currently this going to break ONE_WEEK bonuses because those don't work with CWillLastDays selector.
2015-11-12 14:30:29 +03:00
ArseniyShestakov
9ed9d94009
TurnInfo: first step towards better abstraction
2015-11-12 05:20:32 +03:00