ServerSpellCastEnvironment.cpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * ServerSpellCastEnvironment.cpp, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #include "StdInc.h"
  11. #include "ServerSpellCastEnvironment.h"
  12. #include "CGameHandler.h"
  13. #include "queries/QueriesProcessor.h"
  14. #include "queries/CQuery.h"
  15. #include "../lib/gameState/CGameState.h"
  16. #include "../lib/NetPacks.h"
  17. ///ServerSpellCastEnvironment
  18. ServerSpellCastEnvironment::ServerSpellCastEnvironment(CGameHandler * gh)
  19. : gh(gh)
  20. {
  21. }
  22. bool ServerSpellCastEnvironment::describeChanges() const
  23. {
  24. return true;
  25. }
  26. void ServerSpellCastEnvironment::complain(const std::string & problem)
  27. {
  28. gh->complain(problem);
  29. }
  30. vstd::RNG * ServerSpellCastEnvironment::getRNG()
  31. {
  32. return &gh->getRandomGenerator();
  33. }
  34. void ServerSpellCastEnvironment::apply(CPackForClient * pack)
  35. {
  36. gh->sendAndApply(pack);
  37. }
  38. void ServerSpellCastEnvironment::apply(BattleLogMessage * pack)
  39. {
  40. gh->sendAndApply(pack);
  41. }
  42. void ServerSpellCastEnvironment::apply(BattleStackMoved * pack)
  43. {
  44. gh->sendAndApply(pack);
  45. }
  46. void ServerSpellCastEnvironment::apply(BattleUnitsChanged * pack)
  47. {
  48. gh->sendAndApply(pack);
  49. }
  50. void ServerSpellCastEnvironment::apply(SetStackEffect * pack)
  51. {
  52. gh->sendAndApply(pack);
  53. }
  54. void ServerSpellCastEnvironment::apply(StacksInjured * pack)
  55. {
  56. gh->sendAndApply(pack);
  57. }
  58. void ServerSpellCastEnvironment::apply(BattleObstaclesChanged * pack)
  59. {
  60. gh->sendAndApply(pack);
  61. }
  62. void ServerSpellCastEnvironment::apply(CatapultAttack * pack)
  63. {
  64. gh->sendAndApply(pack);
  65. }
  66. const CGameInfoCallback * ServerSpellCastEnvironment::getCb() const
  67. {
  68. return gh;
  69. }
  70. const CMap * ServerSpellCastEnvironment::getMap() const
  71. {
  72. return gh->gameState()->map;
  73. }
  74. bool ServerSpellCastEnvironment::moveHero(ObjectInstanceID hid, int3 dst, bool teleporting)
  75. {
  76. return gh->moveHero(hid, dst, teleporting, false);
  77. }
  78. void ServerSpellCastEnvironment::genericQuery(Query * request, PlayerColor color, std::function<void(std::optional<int32_t>)> callback)
  79. {
  80. auto query = std::make_shared<CGenericQuery>(gh, color, callback);
  81. request->queryID = query->queryID;
  82. gh->queries->addQuery(query);
  83. gh->sendAndApply(request);
  84. }