1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +02:00
Commit Graph

654 Commits

Author SHA1 Message Date
Aleksei Iupinov
7ed318d156 Stop awarding single scenario bonuses in campaigns 2018-08-05 05:42:54 +03:00
Arseniy Shestakov
ac66fc7f42 Full rework of pre-game interface and networking
New features for players:
* Loading for multiplayer. Any save could be used for multiplayer.
* Restart for multiplayer. All clients will restart together.
* Loading from single save.
* Hotseat mixed with network game. Multiple players per client.
* Now connection to server could be cancelled.
* Return to menu on disconnections instead of crashes.
* Restoring of last selected map, save or campaign on next run.

TLDR on important changes in engine code:
* UI: work with server separated from UI
* UI: all explitic blitting replaced with IntObject's
* UI: all new code use smart pointers instead of DISPOSE
* Gameplay always start through lobby controlled by server.
* Threads receiving netpacks now shared for lobby and gameplay.
* Campaigns: heroes for crossover now serialized as JsonNode.
2018-04-04 14:24:26 +07:00
Henning Koehler
7f76648a7c Extend Bonus.addInfo to integer vector (#427)
* changed Bonus::additionalInfo to integer vector

* fixed deserialization for old savegames

* removed newline from JsonNode::toJson()

* updated bonus schema; SPELL_AFTER_ATTACK and SPELL_BEFORE_ATTACK use new addInfo format

* removed unnecessary init in Bonus constructor
2018-03-12 08:20:18 +03:00
Henning Koehler
d3e4fc6e7a renamed CBonusSystemNode::popBonuses to removeBonusesRecursive 2018-03-05 22:13:23 +08:00
Arseniy Shestakov
8bbe747e8e Cleanup undef for min / max. NOMINMAX is already in Global.h 2018-02-11 05:42:49 +03:00
Ivan Romanov
eea50a044c Hide "this statement may fall through" warnings 2018-02-10 22:27:00 +05:00
AlexVinS
0b70baa95e Spells configuration version 2 (effect-based)
* Indirect spell effects loading
* Json serializer improvements
* spell->canBeCastAt do not allow useless cast for any spell
* Added proxy caster class for spell-created obstacles
* Handle damage from spell-created obstacles inside mechanics
* Experimental GameState integration/regression tests
* Ignore mod settings and load only "vcmi" mod when running tests
* fixed https://bugs.vcmi.eu/view.php?id=2765 (with tests)
* Huge improvements of BattleAI regarding spell casts
* AI can cast almost any combat spell except TELEPORT, SACRIFICE and obstacle placement spells.
* Possible fix for https://bugs.vcmi.eu/view.php?id=1811
* CStack factored out to several classes
* [Battle] Allowed RETURN_AFTER_STRIKE effect on server side to be optional
* [Battle] Allowed BattleAction have multiple destinations
* [Spells] Converted limit|immunity to target condition
* [Spells] Use partial configuration reload for backward compatibility handling
* [Tests] Started tests for CUnitState
* Partial fixes of fire shield effect
* [Battle] Do HP calculations in 64 bits
* [BattleAI] Use threading for spell cast evaluation
* [BattleAI] Made AI be able to evaluate modified turn order (on hypothetical battle state)
* Implemented https://bugs.vcmi.eu/view.php?id=2811
* plug rare freeze when hypnotized unit shots vertically
* Correctly apply ONLY_MELEE_FIGHT / ONLY_DISTANCE_FIGHT for unit damage, attack & defense
* [BattleAI] Try to not waste a cast if battle is actually won already
* Extended JsonSerializeFormat API
* fixed https://bugs.vcmi.eu/view.php?id=2847
* Any unit effect can be now chained (not only damage like Chain Lightning)
** only damage effect for now actually uses "chainFactor"
* Possible quick fix for https://bugs.vcmi.eu/view.php?id=2860
2018-02-08 11:37:21 +03:00
Henning Koehler
abdca71828 skill names and descriptions are fully managed by CSkillHandler 2017-08-30 22:35:23 +12:00
AlexVinS
0868164147 (int) -> static_cast<int> 2017-08-12 15:43:41 +03:00
AlexVinS
8c0fab1dcf fixes 2017-08-12 14:36:37 +03:00
AlexVinS
15138c23de Finished conversion to new logging API
* removed logger streams
* (float3|int3)::operator() -> (float3|int3)::toString(), it was too ugly and confusing.
2017-08-11 23:06:27 +03:00
AlexVinS
61e241308d Logging cleanup 2017-08-10 19:52:05 +03:00
ArseniyShestakov
b52cfe5283 Code style: use parentheses for creating heap-based objects (#344) 2017-07-16 12:58:05 +03:00
ArseniyShestakov
a4c0ad94b1 Code style: remove default value hints in definitions (#342)
Some are outdated and this is something IDE are useful for.
2017-07-15 14:08:20 +03:00
Arseniy Shestakov
4bf1c9a9a3 Campaigns: fix crash on CMap::instanceNames serialization 2017-07-14 15:37:40 +03:00
Arseniy Shestakov
f1e5797834 Code style: move or add licensing information on top of every file 2017-07-14 01:26:03 +03:00
AlexVinS
3d1a84875e Queries refactoring
* Moved SUMMON_BOAT special case to mechanics
* Partially moved Town portal logic to mechanics class
* Added generic query reply to CCallback
* Redesigned Queries so that base API do not depends on CGameHandler
* Got rid of CGameHandler::castSpellRequest
* Removed CGameHandler::castSpell
* Added new Query type for town portal dialog (not used yet)
2017-07-03 21:43:04 +03:00
ArseniyShestakov
2f305cc68d Remove code related to duel mode (#312)
Remove code related to duel mode
2017-07-01 16:30:13 +03:00
FeniksFire
4113bdab01 Moving some files from lib to the battle subdirectory. 2017-06-26 15:26:08 +02:00
AlexVinS
86f9df5f68 Made gamestate lock static 2017-06-14 07:59:41 +03:00
Arseniy Shestakov
18161d3688 Client: implement spectator mode via command-line options
If running with --spectate/-s CPlayerInterface will appear even without human players.
Following command-line options also available:
 --spectate-ignore-hero
 --spectate-hero-speed=N
 --spectate-battle-speed=N
 --spectate-skip-battle
 --spectate-skip-battle-result
Boolean options can also be changed in runtime via client console:
 set spectate-ignore-hero on / off
Spectator mode also:
 - Work with --onlyAI option when starting game or loading saves.
 - Allow to use any cheat codes.
 - Give recon on towns and heroes.
2017-06-06 07:30:16 +03:00
AlexVinS
c82afe7156 switch CMapService API to ResourceID 2017-06-04 22:42:48 +03:00
Alexander Shishkin
7e1b0d71c5 Added option for saving generated maps on client side (#307)
* new configuration option 'general.saveRandomMaps'
* maps being saved to 'userCachePath/RandomMaps'
* no deletion of old random maps
* map filename generated based on template name and random seed
2017-06-04 20:33:28 +03:00
AlexVinS
a85b4cf2a5 * WIP on event condition format
* Hero portrait serialization
* Fix town spells serialization

* Added support for float exponential part in Json
* Added support for int64 in Json
* Added basic Hero definitions serialization
* Added rumors serialization
* Advanced player info serialization.
* Added Disposed heroes serialization, (!) not covered with tests yet
* Added Local event serialization
* Added Pandoras box serialization
* Added Seer hut reward serialization
* Added CQuest serialization
* Added API for map object instance names serialization.
* Added random dwelling options serialization
* Advanced town options serialization
* Advanced hero options serialization
* More map format tests
* A lot of fixes, cleanup and refactoring
2017-05-27 00:23:19 +03:00
FeniksFire
3de891b4b4 Moving/dividing classes from BattleState to separate files. 2017-03-17 16:48:44 +01:00
AlexVinS
3216422307 Fixed a few CWE-457 2016-11-27 22:07:01 +03:00
AlexVinS
8b4f1fc938 Fixed CID 1288850 2016-11-26 22:24:16 +03:00
AlexVinS
713403a0e4 Cleanup 2016-11-13 13:15:36 +03:00
Ivan Savenko
5b76c3f4eb Rebase of codebase changes for refactored serializer
Some of newer fixes not yet merged there and save compatibility a bit off.
2016-10-27 18:12:20 +03:00
AlexVinS
cd5c0b3297 Style tweaks. 2016-10-02 15:22:55 +03:00
Arseniy Shestakov
04eb0e3787 CGameState::battleGetBattlefieldType: avoid crash on tile 0,0,0
Fix issue 2524
2016-10-02 08:39: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
dydzio
68af6a0c19 Refactoring InfoAboutHero + GetHeroInfo 2016-09-28 13:22:33 +02:00
dydzio
d831c087d9 Extending hero info callback
Allow to check battle enemy hero details + adding max spell points to available data
2016-09-27 22:47:24 +02:00
Arseniy Shestakov
c8090c78ec CGameState::updateRumor: fix infinite loop with only one map rumor 2016-09-15 23:22:25 +03:00
Arseniy Shestakov
c8faca8f39 Refactoring: only use RNGs explicitly to avoid bug prone code in future
Now server-side code should always use CRandomGenerator::getDefault which is serialized in GH.
CGameState::getRandomGenerator should be only used from GS code and CPackForClient-based applyGs.
2016-09-11 00:10:46 +03:00
Arseniy Shestakov
70abae9b51 CGameState::battleGetBattlefieldType: use RNG by ref
For now I not sure about proper place for battleGetBattlefieldType so I left it in GS
2016-09-09 23:16:43 +03:00
Arseniy Shestakov
ea63497b19 Move CGameState::setupBattle code to CGameHandler::setupBattle
No reason to keep this code in GS.
2016-09-09 23:16:43 +03:00
Arseniy Shestakov
960d93ff5f CGameState: don't use RNG directly for easier desync debugging
Only access random generator via CGameState::getRandomGenerator
2016-09-09 23:16:42 +03:00
ArseniyShestakov
f4f170bf92 Merge pull request #202 from vcmi/noncopyableBonusSystemNode2
Didn't manage to find any crashes in newly created games. Merging.

Keep in mind that even if most of old saves will load properly some of them still corrupted beyond repair and after some turns they might eventually crash.
2016-09-04 11:06:05 +03:00
DjWarmonger
6791350975 Compile fix (operator = is ambiguous). 2016-08-30 07:50:38 +02:00
Arseniy Shestakov
668cd83ee5 More work on static variable desyncs 2016-08-29 23:07:52 +03:00
Arseniy Shestakov
452e28d183 Remove some useless includes found by cppclean
This of course was tested and shouldn't break anything
2016-08-26 04:42:16 +03:00
AlexVinS
629922f43e Added move constructors for minimum required Bonus system`s classes 2016-08-18 15:03:59 +03:00
AlexVinS
b3e7e2e04a [WiP] Fix one case of bonus node copying. 2016-08-18 15:03:55 +03:00
AlexVinS
1c292205df More logging cleanup 2016-08-12 12:14:10 +03:00
Arseniy Shestakov
10dbbead2d Fix indentation of logging code and around it
That wouldn't be as big issue if problem affected few files, but it everywhere in codebase.
Fixed it everywhere since in most files that is the only code with wrong indentation.
2016-03-12 04:46:21 +03:00
AlexVinS
a59f0c23ce Dedug tweaks 2016-02-13 17:16:00 +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
AlexVinS
1bc41b3ba3 Merge commit '3c844002626f48007a888d4dd8b0b45ec867fc9a' into feature/VCMIMapFormat1
Conflicts:
	lib/mapObjects/CGHeroInstance.cpp
2016-02-03 05:04:44 +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
Vadim Markovtsev
9f3313524e Fix 2160 dismissing a VIP hero 2016-01-27 17:10:19 +03:00
Vadim Markovtsev
40cb48d65e Replace std::remove_if with vstd::erase_if 2016-01-26 10:19:58 +03:00
AlexVinS
89d986fc6a Merge remote-tracking branch 'remotes/origin/develop' into feature/VCMIMapFormat1
Conflicts:
	lib/CArtHandler.h
	lib/mapObjects/MiscObjects.cpp
2016-01-24 15:39:41 +03:00
Arseniy Shestakov
725cce368f CGameState::initStartingBonus: fix amounts for wood and ore bonus
In original game when wood and ore bonus is choosen you always get same amount of both resources.
2016-01-15 20:36:16 +03:00
Arseniy Shestakov
383f754ed1 Starting gold bonuses must be always multiples of 100 2016-01-07 20:51:37 +03:00
AlexVinS
37d0dad70a Merge branch 'develop' into feature/VCMIMapFormat1
Conflicts:
	lib/CArtHandler.cpp
2016-01-01 20:28:52 +03:00
Arseniy Shestakov
9fd1cff090 Refactoring: always use std prefix for shared_ptr, unique_ptr and make_shared
Long time ago it's was used without prefix to make future switch from boost to std version easier.
I discusses this with Ivan and decide to drop these using from Global.h now.

This change wouldn't break anything because there was already code with prefix for each of three cases.
2015-12-29 05:43:33 +03:00
Ivan Savenko
a051a08a46 Merge remote-tracking branch 'origin/issue/2306' into develop 2015-12-18 22:21:11 +02: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
0fab319c73 Merge remote-tracking branch 'remotes/origin/develop' into issue/2306
s reverts commit fa8a282696.

Conflicts:
	AI/VCAI/VCAI.cpp

Conflicts:
	AI/VCAI/VCAI.cpp
	client/windows/CAdvmapInterface.cpp
	lib/CPathfinder.cpp
	lib/CPathfinder.h
2015-12-05 12:56:12 +03:00
AlexVinS
6552acdff6 Check coastal tile OTF 2015-12-05 12:36:29 +03:00
ArseniyShestakov
360ebcce7e Merge pull request #145 from vcmi/feature/tavernRumors
Tavern rumors and Thieves Guild fixes
2015-12-05 03:13:25 +03:00
Ivan Savenko
89bf3592e3 Likely fixed duplicated random heroes 2015-12-05 01:40:23 +02:00
ArseniyShestakov
d856fde73f Rumors: use enum instead of magic numbers and avoid potential crash 2015-12-04 22:58:14 +03:00
ArseniyShestakov
2a63ba148a Thieves Guild: fix tavern map object, lvl 0 when no taverns owned
We also now check not number of towns, but only towns that has tavern built. Also according to original mechanics all taverns always display information based on your number of taverns and not number of taverns of object owner.
2015-12-04 18:38:57 +03:00
ArseniyShestakov
3b3c49420f Thieves Guild: correct number of taverns to access information 2015-12-04 17:52:30 +03:00
ArseniyShestakov
a62ee65d72 Rumors: implement income checking via statsHLP::getIncome
This also fix income ranking in Thieves' Guild
2015-12-01 06:28:08 +03:00
ArseniyShestakov
ffcc5ccdd2 Rumors: implement support for grail terrain rumor 2015-12-01 04:57:52 +03:00
ArseniyShestakov
15273ac0f7 Rumors: avoid repeating of same rumor twice in a row
Multiple rumors of same type can go in a row, but not identical rumors.
2015-12-01 02:14:11 +03:00
ArseniyShestakov
98582d628c Rumors: move code into CGameState and add backward compatability 2015-12-01 00:44:58 +03:00
ArseniyShestakov
b2e1ee5363 CGameState: move two pathfinding-related functions to CPathfinderHelper
Both getMovementCost and getNeighbours have nothing to do with gamestate.
2015-11-10 02:15:27 +03:00
ArseniyShestakov
d3c8ca7c1c Pathfinding: implement duration checking for fly and water walking
Now pathfinder take into account different bonuses for different tuns. So if you only have FLYING_MOVEMENT bonus from Fly spell for one turn then pathfinder will only let you use air layer within one turn only.

That work for cost calculations too. Let's say you have two bonuses:
 - FLYING_MOVEMENT with 20% penalty for next 2 turns
 - FLYING_MOVEMENT with 40% penalty for 5 turns
Now pathfinder using correct penalty for each turn so movements in air layer going to be more expensive on 3-5 turns.
2015-11-09 19:57:26 +03:00
ArseniyShestakov
7eebcb9d60 Artifacts: replace few more ints by ArtifactID 2015-11-07 11:46:58 +03:00
AlexVinS
d46364c4c3 Merge branch 'develop' into issue/2306
Need to reapply changes to pathfiner

Conflicts:
	AI/VCAI/VCAI.cpp
	lib/CGameState.cpp
	lib/CGameStateFwd.h
2015-11-01 01:49:57 +03:00
Vadim Markovtsev
e6e975e9ef Fix adventure map movement segfault in some scenarios 2015-10-31 20:23:13 +03:00
DjWarmonger
17071c6ec8 Merge pull request #125 from ArseniyShestakov/newMovementSystem
Okay, time to merge this.
2015-10-31 13:56:22 +01:00
ArseniyShestakov
6b34eb729e Move all pathfinding-related code into new file 2015-10-27 03:34:47 +03:00
ArseniyShestakov
9e8427a078 CPathfinder: update comment for isSourceGuarded condition 2015-10-27 00:22:40 +03:00
ArseniyShestakov
01257efc02 CPathfinder: get rid of curPos and pass on initializeGraph 2015-10-26 20:17:10 +03:00
ArseniyShestakov
68bd37aa45 Store penalty in value of FLYING_MOVEMENT and WATER_WALKING 2015-10-26 18:30:11 +03:00
ArseniyShestakov
44ca00cd16 CPathfinder: rename functions 2015-10-25 19:11:00 +03:00
ArseniyShestakov
a536691781 CPathfinder: fix typos and more code cleanups 2015-10-25 17:01:28 +03:00
ArseniyShestakov
4f7c3ec60f Minor formatting fixes within pathfinder-related code 2015-10-24 15:50:00 +03:00
ArseniyShestakov
939b3c05a1 CPathfinder: use struct instead of enum for options
Suggested by @DjWarmonger as better alternative from performance standpoint while struct still more organized than bunch of variables.
Other reason of change it's that in future we may need non-boolean options, e.g for patrol movement and some new pathfinder usages.
2015-10-24 15:34:27 +03:00
ArseniyShestakov
6934c6bc95 CPathfinder: move check into isBetterWay lambda
It's must be of course used for teleporters too.
2015-10-24 14:54:15 +03:00
ArseniyShestakov
5a04f05b9b CPathfinder: move one more check into isMovementPossible 2015-10-24 12:09:57 +03:00
ArseniyShestakov
6ebe2abc1a Fix penalties for FLYING_MOVEMENT and WATER_WALKING 2015-10-23 20:50:52 +03:00
ArseniyShestakov
fc6f62e633 getMovementCost: get rid of useless flying parameter 2015-10-19 07:27:00 +03:00
ArseniyShestakov
498eb1d032 Fix typos 2015-10-19 05:16:18 +03:00
Vadim Markovtsev
e4b1ef1405 Add "override" to virtual overriden methods 2015-10-13 21:05:36 +03:00
ArseniyShestakov
9954dfb33a CPathfinder: move flying into options and add walk on sea 2015-10-12 19:03:08 +03:00
ArseniyShestakov
0faedde6b9 CPathfinder: store pathfinding options in set instead of variables
There is plenty of variables now and in future I'm going to add more more once pathfinder become usable for all kind of things.
2015-10-12 10:29:39 +03:00
ArseniyShestakov
886042dc11 CPathfinder: clean calculatePaths of code unsused for pathfinding
Map graph initialization should be there as well because it's needed for path checking.
This change wouldn't affect anything since currently CPathfinder object created from scratch every time.
2015-10-12 08:31:35 +03:00
ArseniyShestakov
213d8c2258 CPathfinder: turn checkDestinationTile into function
This code was only kept as lamba to access guard related variables that is now gone.
2015-10-12 08:22:31 +03:00
ArseniyShestakov
1beacf2260 CPathfinder: move guard checks into functions 2015-10-12 08:13:10 +03:00
ArseniyShestakov
cd7c5acbc4 CPathfinder: move embark special case code down
It's not affect cost calculations any way so let it's be in same order as it's used in condition under it.
2015-10-12 07:26:13 +03:00
ArseniyShestakov
c6f9cd1e52 CPathfinder: move passability checks into renamed goodForLandSeaTransition
There no need in dedicated function for embark / disembark and other conditions belong there perfectly.
This function is going to check what movements are plain impossible so we don't have to bother check their cost.
2015-10-12 07:10:33 +03:00
ArseniyShestakov
ee4305cd6d CPathfinder: move destTopVisObjID where it's belongs to 2015-10-10 19:02:21 +03:00