mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Merge branch 'vcmi:develop' into contitutient-swap
This commit is contained in:
commit
8504102c53
6
Global.h
6
Global.h
@ -746,6 +746,12 @@ namespace vstd
|
||||
}
|
||||
return std::to_string(number) + *iter;
|
||||
}
|
||||
|
||||
///compile-time version of std::abs for ints for int3, in clang++15 std::abs is constexpr
|
||||
static constexpr int abs(int i) {
|
||||
if(i < 0) return -i;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
using vstd::operator-=;
|
||||
|
||||
|
@ -31,6 +31,7 @@
|
||||
"vcmi.systemOptions.resolutionButton.help" : "{Select resolution}\n\n Change in-game screen resolution. Game restart required to apply new resolution.",
|
||||
"vcmi.systemOptions.resolutionMenu.hover" : "Select resolution",
|
||||
"vcmi.systemOptions.resolutionMenu.help" : "Change in-game screen resolution.",
|
||||
"vcmi.systemOptions.fullscreenFailed" : "{Fullscreen}\n\n Failed to switch to fullscreen mode! Current resolution is not supported by display!",
|
||||
|
||||
"vcmi.townHall.missingBase" : "Base building %s must be built first",
|
||||
"vcmi.townHall.noCreaturesToRecruit" : "There are no creatures to recruit!",
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "../../lib/mapObjects/CGHeroInstance.h"
|
||||
#include "../../lib/mapObjects/CObjectClassesHandler.h"
|
||||
#include "../../lib/mapping/CMap.h"
|
||||
#include "../../lib/Color.h"
|
||||
#include "../../lib/CConfigHandler.h"
|
||||
#include "../../lib/CGeneralTextHandler.h"
|
||||
#include "../../lib/CStopWatch.h"
|
||||
@ -925,21 +926,21 @@ void CMapHandler::CMapBlitter::blit(SDL_Surface * targetSurf, const MapDrawingIn
|
||||
{
|
||||
for (realPos.y = initPos.y, pos.y = topTile.y; pos.y < topTile.y + tileCount.y; pos.y++, realPos.y += tileSize)
|
||||
{
|
||||
const int3 color(0x555555, 0x555555, 0x555555);
|
||||
constexpr ColorRGBA color(0x55, 0x55, 0x55);
|
||||
|
||||
if (realPos.y >= info->drawBounds.y &&
|
||||
realPos.y < info->drawBounds.y + info->drawBounds.h)
|
||||
for(int i = 0; i < tileSize; i++)
|
||||
if (realPos.x + i >= info->drawBounds.x &&
|
||||
realPos.x + i < info->drawBounds.x + info->drawBounds.w)
|
||||
CSDL_Ext::putPixelWithoutRefresh(targetSurf, realPos.x + i, realPos.y, color.x, color.y, color.z);
|
||||
CSDL_Ext::putPixelWithoutRefresh(targetSurf, realPos.x + i, realPos.y, color.r, color.g, color.b);
|
||||
|
||||
if (realPos.x >= info->drawBounds.x &&
|
||||
realPos.x < info->drawBounds.x + info->drawBounds.w)
|
||||
for(int i = 0; i < tileSize; i++)
|
||||
if (realPos.y + i >= info->drawBounds.y &&
|
||||
realPos.y + i < info->drawBounds.y + info->drawBounds.h)
|
||||
CSDL_Ext::putPixelWithoutRefresh(targetSurf, realPos.x, realPos.y + i, color.x, color.y, color.z);
|
||||
CSDL_Ext::putPixelWithoutRefresh(targetSurf, realPos.x, realPos.y + i, color.r, color.g, color.b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -49,14 +49,6 @@ SDL_Color CSDL_Ext::toSDL(const ColorRGBA & color)
|
||||
return result;
|
||||
}
|
||||
|
||||
Rect CSDL_Ext::getDisplayBounds()
|
||||
{
|
||||
SDL_Rect displayBounds;
|
||||
SDL_GetDisplayBounds(std::max(0, SDL_GetWindowDisplayIndex(mainWindow)), &displayBounds);
|
||||
|
||||
return fromSDL(displayBounds);
|
||||
}
|
||||
|
||||
void CSDL_Ext::setColors(SDL_Surface *surface, SDL_Color *colors, int firstcolor, int ncolors)
|
||||
{
|
||||
SDL_SetPaletteColors(surface->format->palette,colors,firstcolor,ncolors);
|
||||
@ -878,7 +870,42 @@ void CSDL_Ext::getClipRect(SDL_Surface * src, Rect & other)
|
||||
other = CSDL_Ext::fromSDL(rect);
|
||||
}
|
||||
|
||||
bool CSDL_Ext::isResolutionSupported(const std::vector<Point> & resolutions, const Point toTest )
|
||||
{
|
||||
#if defined(VCMI_ANDROID) || defined(VCMI_IOS)
|
||||
// ios can use any resolution
|
||||
// presumably, same goes for Android
|
||||
return true;
|
||||
#else
|
||||
// in fullscreen only resolutions supported by monitor can be used
|
||||
return vstd::contains(resolutions, toTest);
|
||||
#endif
|
||||
}
|
||||
|
||||
std::vector<Point> CSDL_Ext::getSupportedResolutions()
|
||||
{
|
||||
int displayID = SDL_GetWindowDisplayIndex(mainWindow);
|
||||
return getSupportedResolutions(displayID);
|
||||
}
|
||||
|
||||
std::vector<Point> CSDL_Ext::getSupportedResolutions( int displayIndex)
|
||||
{
|
||||
std::vector<Point> result;
|
||||
|
||||
int modesCount = SDL_GetNumDisplayModes(displayIndex);
|
||||
|
||||
for (int i =0; i < modesCount; ++i)
|
||||
{
|
||||
SDL_DisplayMode mode;
|
||||
if (SDL_GetDisplayMode(displayIndex, i, &mode) != 0)
|
||||
continue;
|
||||
|
||||
Point resolution(mode.w, mode.h);
|
||||
|
||||
result.push_back(resolution);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template SDL_Surface * CSDL_Ext::createSurfaceWithBpp<2>(int, int);
|
||||
template SDL_Surface * CSDL_Ext::createSurfaceWithBpp<3>(int, int);
|
||||
|
@ -81,9 +81,6 @@ typedef void (*TColorPutterAlpha)(uint8_t *&ptr, const uint8_t & R, const uint8_
|
||||
uint32_t colorTouint32_t(const SDL_Color * color); //little endian only
|
||||
SDL_Color makeColor(ui8 r, ui8 g, ui8 b, ui8 a);
|
||||
|
||||
/// returns dimensions of display on which VCMI window is located
|
||||
Rect getDisplayBounds();
|
||||
|
||||
void drawLine(SDL_Surface * sur, int x1, int y1, int x2, int y2, const SDL_Color & color1, const SDL_Color & color2);
|
||||
void drawBorder(SDL_Surface * sur, int x, int y, int w, int h, const SDL_Color &color, int depth = 1);
|
||||
void drawBorder(SDL_Surface * sur, const Rect &r, const SDL_Color &color, int depth = 1);
|
||||
@ -107,6 +104,11 @@ typedef void (*TColorPutterAlpha)(uint8_t *&ptr, const uint8_t & R, const uint8_
|
||||
void applyEffectBpp( SDL_Surface * surf, const Rect & rect, int mode );
|
||||
void applyEffect(SDL_Surface * surf, const Rect & rect, int mode); //mode: 0 - sepia, 1 - grayscale
|
||||
|
||||
bool isResolutionSupported(const std::vector<Point> & resolutions, const Point toTest );
|
||||
|
||||
std::vector<Point> getSupportedResolutions();
|
||||
std::vector<Point> getSupportedResolutions( int displayIndex);
|
||||
|
||||
void setColorKey(SDL_Surface * surface, SDL_Color color);
|
||||
|
||||
///set key-color to 0,255,255
|
||||
|
@ -149,19 +149,12 @@ void CHeroArtPlace::clickLeft(tribool down, bool previousState)
|
||||
select();
|
||||
}
|
||||
}
|
||||
else if(ourArt == ourOwner->commonInfo->src.art) //restore previously picked artifact
|
||||
{
|
||||
deselect();
|
||||
}
|
||||
else //perform artifact transition
|
||||
// Perform artifact transition
|
||||
else if(ourArt != ourOwner->commonInfo->src.art)
|
||||
{
|
||||
if(inBackpack) // Backpack destination.
|
||||
{
|
||||
if(srcInBackpack && slotID == ourOwner->commonInfo->src.slotID + 1) //next slot (our is not visible, so visually same as "old" place) to the art -> make nothing, return artifact to slot
|
||||
{
|
||||
deselect();
|
||||
}
|
||||
else
|
||||
if(!srcInBackpack || slotID != ourOwner->commonInfo->src.slotID + 1)
|
||||
{
|
||||
const CArtifact * const cur = ourOwner->commonInfo->src.art->artType;
|
||||
|
||||
@ -186,9 +179,7 @@ void CHeroArtPlace::clickLeft(tribool down, bool previousState)
|
||||
|| ourOwner->commonInfo->src.slotID < ourOwner->commonInfo->dst.slotID) //rearranging arts in backpack after taking src artifact, the dest id will be shifted
|
||||
vstd::advance(ourOwner->commonInfo->dst.slotID, -1);
|
||||
}
|
||||
if(srcInSameHero && ourOwner->commonInfo->dst.slotID == ourOwner->commonInfo->src.slotID) //we came to src == dst
|
||||
deselect();
|
||||
else
|
||||
if(!srcInSameHero || ourOwner->commonInfo->dst.slotID != ourOwner->commonInfo->src.slotID)
|
||||
ourOwner->realizeCurrentTransaction();
|
||||
}
|
||||
}
|
||||
@ -274,13 +265,13 @@ void CArtifactsOfHero::deactivate()
|
||||
/**
|
||||
* Selects artifact slot so that the containing artifact looks like it's picked up.
|
||||
*/
|
||||
void CHeroArtPlace::select ()
|
||||
void CHeroArtPlace::select()
|
||||
{
|
||||
if (locked)
|
||||
if(locked)
|
||||
return;
|
||||
|
||||
pickSlot(true);
|
||||
if(ourArt->canBeDisassembled() && slotID < GameConstants::BACKPACK_START) //worn combined artifact -> locks have to disappear
|
||||
if(ourArt->canBeDisassembled() && ArtifactUtils::isSlotEquipment(slotID)) //worn combined artifact -> locks have to disappear
|
||||
{
|
||||
for(auto slot : ArtifactUtils::constituentWornSlots())
|
||||
{
|
||||
@ -292,41 +283,10 @@ void CHeroArtPlace::select ()
|
||||
|
||||
CCS->curh->dragAndDropCursor("artifact", ourArt->artType->getIconIndex());
|
||||
ourOwner->commonInfo->src.setTo(this, false);
|
||||
ourOwner->markPossibleSlots(ourArt);
|
||||
ourOwner->commonInfo->src.slotID = ArtifactPosition::TRANSITION_POS;
|
||||
|
||||
if(slotID >= GameConstants::BACKPACK_START)
|
||||
ourOwner->scrollBackpack(0); //will update slots
|
||||
|
||||
ourOwner->updateParentWindow();
|
||||
ourOwner->safeRedraw();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deselects the artifact slot.
|
||||
*/
|
||||
void CHeroArtPlace::deselect ()
|
||||
{
|
||||
pickSlot(false);
|
||||
if(ourArt && ourArt->canBeDisassembled()) //combined art returned to its slot -> restore locks
|
||||
{
|
||||
for(auto slot : ArtifactUtils::constituentWornSlots())
|
||||
{
|
||||
auto place = ourOwner->getArtPlace(slot);
|
||||
|
||||
if(nullptr != place)//getArtPlace may return null
|
||||
place->pickSlot(false);
|
||||
}
|
||||
}
|
||||
|
||||
CCS->curh->dragAndDropCursor(nullptr);
|
||||
ourOwner->unmarkSlots();
|
||||
ourOwner->commonInfo->src.clear();
|
||||
if(slotID >= GameConstants::BACKPACK_START)
|
||||
ourOwner->scrollBackpack(0); //will update slots
|
||||
|
||||
|
||||
ourOwner->updateParentWindow();
|
||||
ourOwner->safeRedraw();
|
||||
LOCPLINT->cb->swapArtifacts(ArtifactLocation(ourOwner->curHero, slotID),
|
||||
ArtifactLocation(ourOwner->curHero, ArtifactPosition::TRANSITION_POS));
|
||||
}
|
||||
|
||||
void CHeroArtPlace::showAll(SDL_Surface * to)
|
||||
@ -760,35 +720,41 @@ void CArtifactsOfHero::artifactMoved(const ArtifactLocation & src, const Artifac
|
||||
commonInfo->src.slotID = src.slot;
|
||||
}
|
||||
// Artifact was taken from us
|
||||
else if(commonInfo->src == src)
|
||||
else if(commonInfo->src == src && dst.slot != ArtifactPosition::TRANSITION_POS)
|
||||
{
|
||||
// Expected movement from slot ot slot
|
||||
assert(commonInfo->dst == dst
|
||||
// Artifact moved back to backpack (eg. to make place for art we are moving)
|
||||
|| dst.slot == dst.getHolderArtSet()->artifactsInBackpack.size() + GameConstants::BACKPACK_START
|
||||
|| dst.slot == dst.getHolderArtSet()->artifactsInBackpack.size() + GameConstants::BACKPACK_START
|
||||
|| dst.getHolderArtSet()->bearerType() != ArtBearer::HERO);
|
||||
commonInfo->reset();
|
||||
unmarkSlots();
|
||||
}
|
||||
// The dest artifact was moved after the swap -> we are picking it
|
||||
else if(commonInfo->dst == src)
|
||||
else
|
||||
{
|
||||
assert(dst.slot == ArtifactPosition::TRANSITION_POS);
|
||||
commonInfo->reset();
|
||||
|
||||
for(CArtifactsOfHero * aoh : commonInfo->participants)
|
||||
// The dest artifact was moved after the swap -> we are picking it
|
||||
if(commonInfo->dst == src)
|
||||
{
|
||||
if(dst.isHolder(aoh->curHero))
|
||||
{
|
||||
commonInfo->src.AOH = aoh;
|
||||
break;
|
||||
}
|
||||
}
|
||||
assert(dst.slot == ArtifactPosition::TRANSITION_POS);
|
||||
commonInfo->reset();
|
||||
|
||||
commonInfo->src.art = dst.getArt();
|
||||
commonInfo->src.slotID = dst.slot;
|
||||
assert(commonInfo->src.AOH);
|
||||
CCS->curh->dragAndDropCursor("artifact", dst.getArt()->artType->getIconIndex());
|
||||
for(CArtifactsOfHero * aoh : commonInfo->participants)
|
||||
{
|
||||
if(dst.isHolder(aoh->curHero))
|
||||
{
|
||||
commonInfo->src.AOH = aoh;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
commonInfo->src.art = dst.getArt();
|
||||
commonInfo->src.slotID = dst.slot;
|
||||
assert(commonInfo->src.AOH);
|
||||
CCS->curh->dragAndDropCursor("artifact", dst.getArt()->artType->getIconIndex());
|
||||
}
|
||||
auto art = dst.getArt();
|
||||
if(art && dst.slot == ArtifactPosition::TRANSITION_POS)
|
||||
markPossibleSlots(art);
|
||||
}
|
||||
|
||||
updateParentWindow();
|
||||
|
@ -90,7 +90,6 @@ public:
|
||||
void clickLeft(tribool down, bool previousState) override;
|
||||
void clickRight(tribool down, bool previousState) override;
|
||||
void select();
|
||||
void deselect();
|
||||
void showAll(SDL_Surface * to) override;
|
||||
bool fitsHere (const CArtifactInstance * art) const; //returns true if given artifact can be placed here
|
||||
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include "../lobby/CSavingScreen.h"
|
||||
#include "../renderSDL/SDL_Extensions.h"
|
||||
#include "../render/CAnimation.h"
|
||||
#include "../CMT.h"
|
||||
|
||||
#include "../../CCallback.h"
|
||||
|
||||
@ -63,6 +64,8 @@
|
||||
#include "../lib/NetPacksBase.h"
|
||||
#include "../lib/StartInfo.h"
|
||||
|
||||
#include <SDL_surface.h>
|
||||
|
||||
CRecruitmentWindow::CCreatureCard::CCreatureCard(CRecruitmentWindow * window, const CCreature * crea, int totalAmount)
|
||||
: CIntObject(LCLICK | RCLICK),
|
||||
parent(window),
|
||||
@ -540,7 +543,7 @@ CSystemOptionsWindow::CSystemOptionsWindow()
|
||||
|
||||
fullscreen = std::make_shared<CToggleButton>(Point(246, 215), "sysopchk.def", CButton::tooltipLocalized("vcmi.systemOptions.fullscreenButton"), [&](bool value)
|
||||
{
|
||||
setBoolSetting("video", "fullscreen", value);
|
||||
setFullscreenMode(value);
|
||||
});
|
||||
fullscreen->setSelected(settings["video"]["fullscreen"].Bool());
|
||||
|
||||
@ -552,27 +555,82 @@ CSystemOptionsWindow::CSystemOptionsWindow()
|
||||
gameResLabel = std::make_shared<CLabel>(170, 292, FONT_MEDIUM, ETextAlignment::CENTER, Colors::YELLOW, resolutionToString(screenRes["width"].Integer(), screenRes["height"].Integer()));
|
||||
}
|
||||
|
||||
void CSystemOptionsWindow::selectGameRes()
|
||||
void CSystemOptionsWindow::setFullscreenMode( bool on)
|
||||
{
|
||||
std::vector<std::string> items;
|
||||
fillSelectableResolutions();
|
||||
|
||||
#ifndef VCMI_IOS
|
||||
Rect displayBounds = CSDL_Ext::getDisplayBounds();
|
||||
#endif
|
||||
const auto & screenRes = settings["video"]["screenRes"];
|
||||
const Point desiredResolution(screenRes["width"].Integer(), screenRes["height"].Integer());
|
||||
const Point currentResolution(screen->w, screen->h);
|
||||
|
||||
if (!isResolutionSupported(currentResolution, on))
|
||||
{
|
||||
fullscreen->setSelected(!on);
|
||||
LOCPLINT->showInfoDialog(CGI->generaltexth->translate("vcmi.systemOptions.fullscreenFailed"));
|
||||
return;
|
||||
}
|
||||
|
||||
setBoolSetting("video", "fullscreen", on);
|
||||
|
||||
if (!isResolutionSupported(desiredResolution, on))
|
||||
{
|
||||
// user changed his desired resolution and switched to fullscreen
|
||||
// however resolution he selected before is not available in fullscreen
|
||||
// so reset it back to currect resolution which is confirmed to be supported earlier
|
||||
Settings gameRes = settings.write["video"]["screenRes"];
|
||||
gameRes["width"].Float() = currentResolution.x;
|
||||
gameRes["height"].Float() = currentResolution.y;
|
||||
|
||||
gameResLabel->setText(resolutionToString(currentResolution.x, currentResolution.y));
|
||||
}
|
||||
}
|
||||
|
||||
void CSystemOptionsWindow::fillSelectableResolutions()
|
||||
{
|
||||
selectableResolutions.clear();
|
||||
|
||||
size_t currentResolutionIndex = 0;
|
||||
size_t i = 0;
|
||||
for(const auto & it : conf.guiOptions)
|
||||
{
|
||||
const auto & resolution = it.first;
|
||||
#ifndef VCMI_IOS
|
||||
if(displayBounds.w < resolution.first || displayBounds.h < resolution.second)
|
||||
continue;
|
||||
#endif
|
||||
const Point dimensions(it.first.first, it.first.second);
|
||||
|
||||
auto resolutionStr = resolutionToString(resolution.first, resolution.second);
|
||||
if(isResolutionSupported(dimensions))
|
||||
selectableResolutions.push_back(dimensions);
|
||||
}
|
||||
|
||||
boost::range::sort(selectableResolutions, [](const auto & left, const auto & right)
|
||||
{
|
||||
return left.x * left.y < right.x * right.y;
|
||||
});
|
||||
}
|
||||
|
||||
bool CSystemOptionsWindow::isResolutionSupported(const Point & resolution)
|
||||
{
|
||||
return isResolutionSupported( resolution, settings["video"]["fullscreen"].Bool());
|
||||
}
|
||||
|
||||
bool CSystemOptionsWindow::isResolutionSupported(const Point & resolution, bool fullscreen)
|
||||
{
|
||||
if (!fullscreen)
|
||||
return true;
|
||||
|
||||
auto supportedList = CSDL_Ext::getSupportedResolutions();
|
||||
|
||||
return CSDL_Ext::isResolutionSupported(supportedList, resolution);
|
||||
}
|
||||
|
||||
void CSystemOptionsWindow::selectGameRes()
|
||||
{
|
||||
fillSelectableResolutions();
|
||||
|
||||
std::vector<std::string> items;
|
||||
size_t currentResolutionIndex = 0;
|
||||
size_t i = 0;
|
||||
for(const auto & it : selectableResolutions)
|
||||
{
|
||||
auto resolutionStr = resolutionToString(it.x, it.y);
|
||||
if(gameResLabel->getText() == resolutionStr)
|
||||
currentResolutionIndex = i;
|
||||
|
||||
items.push_back(std::move(resolutionStr));
|
||||
++i;
|
||||
}
|
||||
@ -586,20 +644,21 @@ void CSystemOptionsWindow::selectGameRes()
|
||||
|
||||
void CSystemOptionsWindow::setGameRes(int index)
|
||||
{
|
||||
auto iter = conf.guiOptions.begin();
|
||||
std::advance(iter, index);
|
||||
assert(index >= 0 && index < selectableResolutions.size());
|
||||
|
||||
//do not set resolution to illegal one (0x0)
|
||||
assert(iter!=conf.guiOptions.end() && iter->first.first > 0 && iter->first.second > 0);
|
||||
if ( index < 0 || index >= selectableResolutions.size() )
|
||||
return;
|
||||
|
||||
Point resolution = selectableResolutions[index];
|
||||
|
||||
Settings gameRes = settings.write["video"]["screenRes"];
|
||||
gameRes["width"].Float() = iter->first.first;
|
||||
gameRes["height"].Float() = iter->first.second;
|
||||
gameRes["width"].Float() = resolution.x;
|
||||
gameRes["height"].Float() = resolution.y;
|
||||
|
||||
std::string resText;
|
||||
resText += boost::lexical_cast<std::string>(iter->first.first);
|
||||
resText += std::to_string(resolution.x);
|
||||
resText += "x";
|
||||
resText += boost::lexical_cast<std::string>(iter->first.second);
|
||||
resText += std::to_string(resolution.y);
|
||||
gameResLabel->setText(resText);
|
||||
}
|
||||
|
||||
|
@ -226,6 +226,9 @@ private:
|
||||
|
||||
SettingsListener onFullscreenChanged;
|
||||
|
||||
std::vector<Point> supportedResolutions;
|
||||
std::vector<Point> selectableResolutions;
|
||||
|
||||
//functions bound to buttons
|
||||
void bloadf(); //load game
|
||||
void bsavef(); //save game
|
||||
@ -234,6 +237,11 @@ private:
|
||||
void brestartf(); //restart game
|
||||
void bmainmenuf(); //return to main menu
|
||||
|
||||
void setFullscreenMode( bool on);
|
||||
void fillSelectableResolutions();
|
||||
bool isResolutionSupported(const Point & resolution);
|
||||
bool isResolutionSupported(const Point & resolution, bool fullscreen);
|
||||
|
||||
void selectGameRes();
|
||||
void setGameRes(int index);
|
||||
void closeAndPushEvent(EUserEvent code);
|
||||
|
@ -1366,8 +1366,10 @@ const ArtSlotInfo * CArtifactSet::getSlot(ArtifactPosition pos) const
|
||||
if(pos == ArtifactPosition::TRANSITION_POS)
|
||||
{
|
||||
// Always add to the end. Always take from the beginning.
|
||||
assert(!artifactsTransitionPos.empty());
|
||||
return &(*artifactsTransitionPos.begin());
|
||||
if(artifactsTransitionPos.empty())
|
||||
return nullptr;
|
||||
else
|
||||
return &(*artifactsTransitionPos.begin());
|
||||
}
|
||||
if(vstd::contains(artifactsWorn, pos))
|
||||
return &artifactsWorn.at(pos);
|
||||
|
@ -274,7 +274,7 @@ DLL_LINKAGE std::string MetaString::buildList () const
|
||||
return lista;
|
||||
}
|
||||
|
||||
void MetaString::addCreReplacement(CreatureID id, TQuantity count) //adds sing or plural name;
|
||||
void MetaString::addCreReplacement(const CreatureID & id, TQuantity count) //adds sing or plural name;
|
||||
{
|
||||
if (!count)
|
||||
addReplacement (CRE_PL_NAMES, id); //no creatures - just empty name (eg. defeat Angels)
|
||||
|
@ -27,7 +27,7 @@ public:
|
||||
uint8_t a;
|
||||
|
||||
//constructors
|
||||
ColorRGBA()
|
||||
constexpr ColorRGBA()
|
||||
:r(0)
|
||||
,g(0)
|
||||
,b(0)
|
||||
@ -35,14 +35,14 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
ColorRGBA(uint8_t r, uint8_t g, uint8_t b, uint8_t a)
|
||||
constexpr ColorRGBA(uint8_t r, uint8_t g, uint8_t b, uint8_t a)
|
||||
: r(r)
|
||||
, g(g)
|
||||
, b(b)
|
||||
, a(a)
|
||||
{}
|
||||
|
||||
ColorRGBA(uint8_t r, uint8_t g, uint8_t b)
|
||||
constexpr ColorRGBA(uint8_t r, uint8_t g, uint8_t b)
|
||||
: r(r)
|
||||
, g(g)
|
||||
, b(b)
|
||||
|
@ -16,7 +16,7 @@ VCMI_LIB_NAMESPACE_BEGIN
|
||||
template <typename T>
|
||||
class ConstTransitivePtr
|
||||
{
|
||||
T *ptr;
|
||||
T *ptr = nullptr;
|
||||
ConstTransitivePtr(const T *Ptr)
|
||||
: ptr(const_cast<T*>(Ptr))
|
||||
{}
|
||||
@ -25,10 +25,7 @@ public:
|
||||
: ptr(Ptr)
|
||||
{}
|
||||
ConstTransitivePtr(std::nullptr_t)
|
||||
: ptr(nullptr)
|
||||
{}
|
||||
|
||||
|
||||
const T& operator*() const
|
||||
{
|
||||
return *ptr;
|
||||
|
747
lib/NetPacks.h
747
lib/NetPacks.h
File diff suppressed because it is too large
Load Diff
@ -34,8 +34,8 @@ struct DLL_LINKAGE CPack
|
||||
{
|
||||
std::shared_ptr<CConnection> c; // Pointer to connection that pack received from
|
||||
|
||||
CPack() : c(nullptr) {};
|
||||
virtual ~CPack() {};
|
||||
CPack() = default;
|
||||
virtual ~CPack() = default;
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
@ -49,8 +49,6 @@ struct DLL_LINKAGE CPack
|
||||
|
||||
struct CPackForClient : public CPack
|
||||
{
|
||||
CPackForClient(){};
|
||||
|
||||
CGameState* GS(CClient *cl);
|
||||
void applyFirstCl(CClient *cl)//called before applying to gs
|
||||
{}
|
||||
@ -60,14 +58,9 @@ struct CPackForClient : public CPack
|
||||
|
||||
struct CPackForServer : public CPack
|
||||
{
|
||||
mutable PlayerColor player;
|
||||
mutable PlayerColor player = PlayerColor::NEUTRAL;
|
||||
mutable si32 requestID;
|
||||
CGameState* GS(CGameHandler *gh);
|
||||
CPackForServer():
|
||||
player(PlayerColor::NEUTRAL)
|
||||
{
|
||||
}
|
||||
|
||||
CGameState * GS(CGameHandler * gh);
|
||||
bool applyGh(CGameHandler *gh) //called after applying to gs
|
||||
{
|
||||
logGlobal->error("Should not happen... applying plain CPackForServer");
|
||||
@ -115,7 +108,7 @@ public:
|
||||
void addTxt(ui8 type, ui32 serial)
|
||||
{
|
||||
message.push_back(TLOCAL_STRING);
|
||||
localStrings.push_back(std::pair<ui8,ui32>(type, serial));
|
||||
localStrings.emplace_back(type, serial);
|
||||
}
|
||||
MetaString& operator<<(const std::pair<ui8,ui32> &txt)
|
||||
{
|
||||
@ -138,7 +131,7 @@ public:
|
||||
void addReplacement(ui8 type, ui32 serial)
|
||||
{
|
||||
message.push_back(TREPLACE_LSTRING);
|
||||
localStrings.push_back(std::pair<ui8,ui32>(type, serial));
|
||||
localStrings.emplace_back(type, serial);
|
||||
}
|
||||
void addReplacement(const std::string &txt)
|
||||
{
|
||||
@ -155,7 +148,7 @@ public:
|
||||
message.push_back(TREPLACE_PLUSNUMBER);
|
||||
numbers.push_back(txt);
|
||||
}
|
||||
void addCreReplacement(CreatureID id, TQuantity count); //adds sing or plural name;
|
||||
void addCreReplacement(const CreatureID & id, TQuantity count); //adds sing or plural name;
|
||||
void addReplacement(const CStackBasicDescriptor &stack); //adds sing or plural name;
|
||||
std::string buildList () const;
|
||||
void clear()
|
||||
@ -167,17 +160,16 @@ public:
|
||||
}
|
||||
void toString(std::string &dst) const;
|
||||
std::string toString() const;
|
||||
void getLocalString(const std::pair<ui8,ui32> &txt, std::string &dst) const;
|
||||
void getLocalString(const std::pair<ui8, ui32> & txt, std::string & dst) const;
|
||||
|
||||
MetaString(){}
|
||||
};
|
||||
|
||||
struct Component
|
||||
{
|
||||
enum EComponentType {PRIM_SKILL, SEC_SKILL, RESOURCE, CREATURE, ARTIFACT, EXPERIENCE, SPELL, MORALE, LUCK, BUILDING, HERO_PORTRAIT, FLAG};
|
||||
ui16 id, subtype; //id uses ^^^ enums, when id==EXPPERIENCE subtype==0 means exp points and subtype==1 levels)
|
||||
si32 val; // + give; - take
|
||||
si16 when; // 0 - now; +x - within x days; -x - per x days
|
||||
ui16 id = 0, subtype = 0; //id uses ^^^ enums, when id==EXPPERIENCE subtype==0 means exp points and subtype==1 levels)
|
||||
si32 val = 0; // + give; - take
|
||||
si16 when = 0; // 0 - now; +x - within x days; -x - per x days
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
@ -186,10 +178,7 @@ struct Component
|
||||
h & val;
|
||||
h & when;
|
||||
}
|
||||
Component()
|
||||
:id(0), subtype(0), val(0), when(0)
|
||||
{
|
||||
}
|
||||
Component() = default;
|
||||
DLL_LINKAGE explicit Component(const CStackBasicDescriptor &stack);
|
||||
Component(Component::EComponentType Type, ui16 Subtype, si32 Val, si16 When)
|
||||
:id(Type),subtype(Subtype),val(Val),when(When)
|
||||
@ -197,28 +186,27 @@ struct Component
|
||||
}
|
||||
};
|
||||
|
||||
typedef boost::variant<ConstTransitivePtr<CGHeroInstance>, ConstTransitivePtr<CStackInstance> > TArtHolder;
|
||||
using TArtHolder = boost::variant<ConstTransitivePtr<CGHeroInstance>, ConstTransitivePtr<CStackInstance>>;
|
||||
|
||||
struct ArtifactLocation
|
||||
{
|
||||
TArtHolder artHolder;//TODO: identify holder by id
|
||||
ArtifactPosition slot;
|
||||
ArtifactPosition slot = ArtifactPosition::PRE_FIRST;
|
||||
|
||||
ArtifactLocation()
|
||||
: artHolder(ConstTransitivePtr<CGHeroInstance>())
|
||||
{
|
||||
artHolder = ConstTransitivePtr<CGHeroInstance>();
|
||||
slot = ArtifactPosition::PRE_FIRST;
|
||||
}
|
||||
template <typename T>
|
||||
ArtifactLocation(const T *ArtHolder, ArtifactPosition Slot)
|
||||
template<typename T>
|
||||
ArtifactLocation(const T * ArtHolder, ArtifactPosition Slot)
|
||||
: artHolder(const_cast<T *>(ArtHolder)) //we are allowed here to const cast -> change will go through one of our packages... do not abuse!
|
||||
, slot(Slot)
|
||||
{
|
||||
artHolder = const_cast<T*>(ArtHolder); //we are allowed here to const cast -> change will go through one of our packages... do not abuse!
|
||||
slot = Slot;
|
||||
}
|
||||
ArtifactLocation(TArtHolder ArtHolder, ArtifactPosition Slot)
|
||||
ArtifactLocation(TArtHolder ArtHolder, const ArtifactPosition & Slot)
|
||||
: artHolder(std::move(std::move(ArtHolder)))
|
||||
, slot(Slot)
|
||||
{
|
||||
artHolder = ArtHolder;
|
||||
slot = Slot;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@ -253,15 +241,9 @@ struct ArtifactLocation
|
||||
class EntityChanges
|
||||
{
|
||||
public:
|
||||
Metatype metatype;
|
||||
int32_t entityIndex;
|
||||
Metatype metatype = Metatype::UNKNOWN;
|
||||
int32_t entityIndex = 0;
|
||||
JsonNode data;
|
||||
EntityChanges()
|
||||
: metatype(Metatype::UNKNOWN),
|
||||
entityIndex(0),
|
||||
data()
|
||||
{
|
||||
}
|
||||
template <typename Handler> void serialize(Handler & h, const int version)
|
||||
{
|
||||
h & metatype;
|
||||
@ -284,17 +266,11 @@ public:
|
||||
};
|
||||
|
||||
JsonNode data;
|
||||
EOperation operation;
|
||||
|
||||
BattleChanges()
|
||||
: operation(EOperation::RESET_STATE),
|
||||
data()
|
||||
{
|
||||
}
|
||||
EOperation operation = EOperation::RESET_STATE;
|
||||
|
||||
BattleChanges() = default;
|
||||
BattleChanges(EOperation operation_)
|
||||
: operation(operation_),
|
||||
data()
|
||||
: operation(operation_)
|
||||
{
|
||||
}
|
||||
};
|
||||
@ -302,20 +278,13 @@ public:
|
||||
class UnitChanges : public BattleChanges
|
||||
{
|
||||
public:
|
||||
uint32_t id;
|
||||
int64_t healthDelta;
|
||||
|
||||
UnitChanges()
|
||||
: BattleChanges(EOperation::RESET_STATE),
|
||||
id(0),
|
||||
healthDelta(0)
|
||||
{
|
||||
}
|
||||
uint32_t id = 0;
|
||||
int64_t healthDelta = 0;
|
||||
|
||||
UnitChanges() = default;
|
||||
UnitChanges(uint32_t id_, EOperation operation_)
|
||||
: BattleChanges(operation_),
|
||||
id(id_),
|
||||
healthDelta(0)
|
||||
: BattleChanges(operation_)
|
||||
, id(id_)
|
||||
{
|
||||
}
|
||||
|
||||
@ -331,13 +300,9 @@ public:
|
||||
class ObstacleChanges : public BattleChanges
|
||||
{
|
||||
public:
|
||||
uint32_t id;
|
||||
uint32_t id = 0;
|
||||
|
||||
ObstacleChanges()
|
||||
: BattleChanges(EOperation::RESET_STATE),
|
||||
id(0)
|
||||
{
|
||||
}
|
||||
ObstacleChanges() = default;
|
||||
|
||||
ObstacleChanges(uint32_t id_, EOperation operation_)
|
||||
: BattleChanges(operation_),
|
||||
|
@ -31,8 +31,7 @@
|
||||
|
||||
VCMI_LIB_NAMESPACE_BEGIN
|
||||
|
||||
|
||||
DLL_LINKAGE void SetResources::applyGs(CGameState *gs)
|
||||
DLL_LINKAGE void SetResources::applyGs(CGameState * gs) const
|
||||
{
|
||||
assert(player < PlayerColor::PLAYER_LIMIT);
|
||||
if(abs)
|
||||
@ -46,14 +45,14 @@ DLL_LINKAGE void SetResources::applyGs(CGameState *gs)
|
||||
gs->getPlayerState(player)->resources.positive();
|
||||
}
|
||||
|
||||
DLL_LINKAGE void SetPrimSkill::applyGs(CGameState *gs)
|
||||
DLL_LINKAGE void SetPrimSkill::applyGs(CGameState * gs) const
|
||||
{
|
||||
CGHeroInstance * hero = gs->getHero(id);
|
||||
assert(hero);
|
||||
hero->setPrimarySkill(which, val, abs);
|
||||
}
|
||||
|
||||
DLL_LINKAGE void SetSecSkill::applyGs(CGameState *gs)
|
||||
DLL_LINKAGE void SetSecSkill::applyGs(CGameState * gs) const
|
||||
{
|
||||
CGHeroInstance *hero = gs->getHero(id);
|
||||
hero->setSecSkillLevel(which, val, abs);
|
||||
@ -88,17 +87,17 @@ DLL_LINKAGE void SetCommanderProperty::applyGs(CGameState *gs)
|
||||
}
|
||||
}
|
||||
|
||||
DLL_LINKAGE void AddQuest::applyGs(CGameState *gs)
|
||||
DLL_LINKAGE void AddQuest::applyGs(CGameState * gs) const
|
||||
{
|
||||
assert (vstd::contains(gs->players, player));
|
||||
auto vec = &gs->players[player].quests;
|
||||
auto * vec = &gs->players[player].quests;
|
||||
if (!vstd::contains(*vec, quest))
|
||||
vec->push_back (quest);
|
||||
else
|
||||
logNetwork->warn("Warning! Attempt to add duplicated quest");
|
||||
}
|
||||
|
||||
DLL_LINKAGE void UpdateArtHandlerLists::applyGs(CGameState *gs)
|
||||
DLL_LINKAGE void UpdateArtHandlerLists::applyGs(CGameState * gs) const
|
||||
{
|
||||
VLC->arth->minors = minors;
|
||||
VLC->arth->majors = majors;
|
||||
@ -106,24 +105,23 @@ DLL_LINKAGE void UpdateArtHandlerLists::applyGs(CGameState *gs)
|
||||
VLC->arth->relics = relics;
|
||||
}
|
||||
|
||||
DLL_LINKAGE void UpdateMapEvents::applyGs(CGameState *gs)
|
||||
DLL_LINKAGE void UpdateMapEvents::applyGs(CGameState * gs) const
|
||||
{
|
||||
gs->map->events = events;
|
||||
}
|
||||
|
||||
|
||||
DLL_LINKAGE void UpdateCastleEvents::applyGs(CGameState *gs)
|
||||
DLL_LINKAGE void UpdateCastleEvents::applyGs(CGameState * gs) const
|
||||
{
|
||||
auto t = gs->getTown(town);
|
||||
auto * t = gs->getTown(town);
|
||||
t->events = events;
|
||||
}
|
||||
|
||||
DLL_LINKAGE void ChangeFormation::applyGs(CGameState *gs)
|
||||
DLL_LINKAGE void ChangeFormation::applyGs(CGameState * gs) const
|
||||
{
|
||||
gs->getHero(hid)->setFormation(formation);
|
||||
}
|
||||
|
||||
DLL_LINKAGE void HeroVisitCastle::applyGs(CGameState *gs)
|
||||
DLL_LINKAGE void HeroVisitCastle::applyGs(CGameState * gs) const
|
||||
{
|
||||
CGHeroInstance *h = gs->getHero(hid);
|
||||
CGTownInstance *t = gs->getTown(tid);
|
||||
@ -142,14 +140,14 @@ DLL_LINKAGE void ChangeSpells::applyGs(CGameState *gs)
|
||||
CGHeroInstance *hero = gs->getHero(hid);
|
||||
|
||||
if(learn)
|
||||
for(auto sid : spells)
|
||||
for(const auto & sid : spells)
|
||||
hero->addSpellToSpellbook(sid);
|
||||
else
|
||||
for(auto sid : spells)
|
||||
for(const auto & sid : spells)
|
||||
hero->removeSpellFromSpellbook(sid);
|
||||
}
|
||||
|
||||
DLL_LINKAGE void SetMana::applyGs(CGameState *gs)
|
||||
DLL_LINKAGE void SetMana::applyGs(CGameState * gs) const
|
||||
{
|
||||
CGHeroInstance * hero = gs->getHero(hid);
|
||||
|
||||
@ -163,7 +161,7 @@ DLL_LINKAGE void SetMana::applyGs(CGameState *gs)
|
||||
vstd::amax(hero->mana, 0); //not less than 0
|
||||
}
|
||||
|
||||
DLL_LINKAGE void SetMovePoints::applyGs(CGameState *gs)
|
||||
DLL_LINKAGE void SetMovePoints::applyGs(CGameState * gs) const
|
||||
{
|
||||
CGHeroInstance *hero = gs->getHero(hid);
|
||||
|
||||
@ -181,7 +179,7 @@ DLL_LINKAGE void FoWChange::applyGs(CGameState *gs)
|
||||
{
|
||||
TeamState * team = gs->getPlayerTeam(player);
|
||||
auto fogOfWarMap = team->fogOfWarMap;
|
||||
for(int3 t : tiles)
|
||||
for(const int3 & t : tiles)
|
||||
(*fogOfWarMap)[t.z][t.x][t.y] = mode;
|
||||
if (mode == 0) //do not hide too much
|
||||
{
|
||||
@ -203,7 +201,7 @@ DLL_LINKAGE void FoWChange::applyGs(CGameState *gs)
|
||||
}
|
||||
}
|
||||
}
|
||||
for(int3 t : tilesRevealed) //probably not the most optimal solution ever
|
||||
for(const int3 & t : tilesRevealed) //probably not the most optimal solution ever
|
||||
(*fogOfWarMap)[t.z][t.x][t.y] = 1;
|
||||
}
|
||||
}
|
||||
@ -218,7 +216,7 @@ DLL_LINKAGE void SetAvailableHeroes::applyGs(CGameState *gs)
|
||||
CGHeroInstance *h = (hid[i]>=0 ? gs->hpool.heroesPool[hid[i]].get() : nullptr);
|
||||
if(h && army[i])
|
||||
h->setToArmy(army[i]);
|
||||
p->availableHeroes.push_back(h);
|
||||
p->availableHeroes.emplace_back(h);
|
||||
}
|
||||
}
|
||||
|
||||
@ -248,8 +246,7 @@ DLL_LINKAGE void GiveBonus::applyGs(CGameState *gs)
|
||||
|
||||
std::string &descr = b->description;
|
||||
|
||||
if(!bdescr.message.size()
|
||||
&& (bonus.type == Bonus::LUCK || bonus.type == Bonus::MORALE))
|
||||
if(bdescr.message.empty() && (bonus.type == Bonus::LUCK || bonus.type == Bonus::MORALE))
|
||||
{
|
||||
if (bonus.source == Bonus::OBJECT)
|
||||
{
|
||||
@ -270,8 +267,8 @@ DLL_LINKAGE void GiveBonus::applyGs(CGameState *gs)
|
||||
bdescr.toString(descr);
|
||||
}
|
||||
// Some of(?) versions of H3 use %s here instead of %d. Try to replace both of them
|
||||
boost::replace_first(descr,"%d",boost::lexical_cast<std::string>(std::abs(bonus.val)));
|
||||
boost::replace_first(descr,"%s",boost::lexical_cast<std::string>(std::abs(bonus.val)));
|
||||
boost::replace_first(descr, "%d", std::to_string(std::abs(bonus.val)));
|
||||
boost::replace_first(descr, "%s", std::to_string(std::abs(bonus.val)));
|
||||
}
|
||||
|
||||
DLL_LINKAGE void ChangeObjPos::applyGs(CGameState *gs)
|
||||
@ -287,7 +284,7 @@ DLL_LINKAGE void ChangeObjPos::applyGs(CGameState *gs)
|
||||
gs->map->addBlockVisTiles(obj);
|
||||
}
|
||||
|
||||
DLL_LINKAGE void ChangeObjectVisitors::applyGs(CGameState *gs)
|
||||
DLL_LINKAGE void ChangeObjectVisitors::applyGs(CGameState * gs) const
|
||||
{
|
||||
switch (mode) {
|
||||
case VISITOR_ADD:
|
||||
@ -297,7 +294,7 @@ DLL_LINKAGE void ChangeObjectVisitors::applyGs(CGameState *gs)
|
||||
case VISITOR_ADD_TEAM:
|
||||
{
|
||||
TeamState *ts = gs->getPlayerTeam(gs->getHero(hero)->tempOwner);
|
||||
for (auto & color : ts->players)
|
||||
for(const auto & color : ts->players)
|
||||
{
|
||||
gs->getPlayerState(color)->visitedObjects.insert(object);
|
||||
}
|
||||
@ -324,7 +321,7 @@ DLL_LINKAGE void ChangeObjectVisitors::applyGs(CGameState *gs)
|
||||
}
|
||||
}
|
||||
|
||||
DLL_LINKAGE void PlayerEndsGame::applyGs(CGameState *gs)
|
||||
DLL_LINKAGE void PlayerEndsGame::applyGs(CGameState * gs) const
|
||||
{
|
||||
PlayerState *p = gs->getPlayerState(player);
|
||||
if(victoryLossCheckResult.victory())
|
||||
@ -374,14 +371,14 @@ DLL_LINKAGE void PlayerReinitInterface::applyGs(CGameState *gs)
|
||||
//TODO: what does mean if more that one player connected?
|
||||
if(playerConnectionId == PlayerSettings::PLAYER_AI)
|
||||
{
|
||||
for(auto player : players)
|
||||
for(const auto & player : players)
|
||||
gs->scenarioOps->getIthPlayersSettings(player).connectedPlayerIDs.clear();
|
||||
}
|
||||
}
|
||||
|
||||
DLL_LINKAGE void RemoveBonus::applyGs(CGameState *gs)
|
||||
{
|
||||
CBonusSystemNode *node;
|
||||
CBonusSystemNode * node = nullptr;
|
||||
if (who == HERO)
|
||||
node = gs->getHero(ObjectInstanceID(whoID));
|
||||
else
|
||||
@ -389,9 +386,8 @@ DLL_LINKAGE void RemoveBonus::applyGs(CGameState *gs)
|
||||
|
||||
BonusList &bonuses = node->getExportedBonusList();
|
||||
|
||||
for (int i = 0; i < bonuses.size(); i++)
|
||||
for(const auto & b : bonuses)
|
||||
{
|
||||
auto b = bonuses[i];
|
||||
if(b->source == source && b->sid == id)
|
||||
{
|
||||
bonus = *b; //backup bonus (to show to interfaces later)
|
||||
@ -411,7 +407,8 @@ DLL_LINKAGE void RemoveObject::applyGs(CGameState *gs)
|
||||
|
||||
if(obj->ID == Obj::HERO) //remove beaten hero
|
||||
{
|
||||
CGHeroInstance * beatenHero = static_cast<CGHeroInstance*>(obj);
|
||||
auto * beatenHero = dynamic_cast<CGHeroInstance *>(obj);
|
||||
assert(beatenHero);
|
||||
PlayerState * p = gs->getPlayerState(beatenHero->tempOwner);
|
||||
gs->map->heroesOnMap -= beatenHero;
|
||||
p->heroes -= beatenHero;
|
||||
@ -450,7 +447,7 @@ DLL_LINKAGE void RemoveObject::applyGs(CGameState *gs)
|
||||
return;
|
||||
}
|
||||
|
||||
auto quest = dynamic_cast<const IQuestObject *>(obj);
|
||||
const auto * quest = dynamic_cast<const IQuestObject *>(obj);
|
||||
if (quest)
|
||||
{
|
||||
gs->map->quests[quest->quest->qid] = nullptr;
|
||||
@ -492,7 +489,7 @@ DLL_LINKAGE void RemoveObject::applyGs(CGameState *gs)
|
||||
gs->map->calculateGuardingGreaturePositions();
|
||||
}
|
||||
|
||||
static int getDir(int3 src, int3 dst)
|
||||
static int getDir(const int3 & src, const int3 & dst)
|
||||
{
|
||||
int ret = -1;
|
||||
if(dst.x+1 == src.x && dst.y+1 == src.y) //tl
|
||||
@ -553,7 +550,8 @@ void TryMoveHero::applyGs(CGameState *gs)
|
||||
{
|
||||
const TerrainTile &tt = gs->map->getTile(h->convertToVisitablePos(end));
|
||||
assert(tt.visitableObjects.size() >= 1 && tt.visitableObjects.back()->ID == Obj::BOAT); //the only visitable object at destination is Boat
|
||||
CGBoat *boat = static_cast<CGBoat*>(tt.visitableObjects.back());
|
||||
auto * boat = dynamic_cast<CGBoat *>(tt.visitableObjects.back());
|
||||
assert(boat);
|
||||
|
||||
gs->map->removeBlockVisTiles(boat); //hero blockvis mask will be used, we don't need to duplicate it with boat
|
||||
h->boat = boat;
|
||||
@ -561,7 +559,7 @@ void TryMoveHero::applyGs(CGameState *gs)
|
||||
}
|
||||
else if(result == DISEMBARK) //hero leaves boat to destination tile
|
||||
{
|
||||
CGBoat *b = const_cast<CGBoat *>(h->boat);
|
||||
auto * b = const_cast<CGBoat *>(h->boat);
|
||||
b->direction = h->moveDir;
|
||||
b->pos = start;
|
||||
b->hero = nullptr;
|
||||
@ -573,13 +571,13 @@ void TryMoveHero::applyGs(CGameState *gs)
|
||||
{
|
||||
gs->map->removeBlockVisTiles(h);
|
||||
h->pos = end;
|
||||
if(CGBoat *b = const_cast<CGBoat *>(h->boat))
|
||||
if(auto * b = const_cast<CGBoat *>(h->boat))
|
||||
b->pos = end;
|
||||
gs->map->addBlockVisTiles(h);
|
||||
}
|
||||
|
||||
auto fogOfWarMap = gs->getPlayerTeam(h->getOwner())->fogOfWarMap;
|
||||
for(int3 t : fowRevealed)
|
||||
for(const int3 & t : fowRevealed)
|
||||
(*fogOfWarMap)[t.z][t.x][t.y] = 1;
|
||||
}
|
||||
|
||||
@ -597,7 +595,7 @@ DLL_LINKAGE void NewStructures::applyGs(CGameState *gs)
|
||||
if(currentBuilding->overrideBids.empty())
|
||||
continue;
|
||||
|
||||
for(auto overrideBid : currentBuilding->overrideBids)
|
||||
for(const auto & overrideBid : currentBuilding->overrideBids)
|
||||
{
|
||||
t->overriddenBuildings.insert(overrideBid);
|
||||
t->deleteTownBonus(overrideBid);
|
||||
@ -620,19 +618,19 @@ DLL_LINKAGE void RazeStructures::applyGs(CGameState *gs)
|
||||
t->recreateBuildingsBonuses();
|
||||
}
|
||||
|
||||
DLL_LINKAGE void SetAvailableCreatures::applyGs(CGameState *gs)
|
||||
DLL_LINKAGE void SetAvailableCreatures::applyGs(CGameState * gs) const
|
||||
{
|
||||
CGDwelling *dw = dynamic_cast<CGDwelling*>(gs->getObjInstance(tid));
|
||||
auto * dw = dynamic_cast<CGDwelling *>(gs->getObjInstance(tid));
|
||||
assert(dw);
|
||||
dw->creatures = creatures;
|
||||
}
|
||||
|
||||
DLL_LINKAGE void SetHeroesInTown::applyGs(CGameState *gs)
|
||||
DLL_LINKAGE void SetHeroesInTown::applyGs(CGameState * gs) const
|
||||
{
|
||||
CGTownInstance *t = gs->getTown(tid);
|
||||
|
||||
CGHeroInstance *v = gs->getHero(visiting),
|
||||
*g = gs->getHero(garrison);
|
||||
CGHeroInstance * v = gs->getHero(visiting);
|
||||
CGHeroInstance * g = gs->getHero(garrison);
|
||||
|
||||
bool newVisitorComesFromGarrison = v && v == t->garrisonHero;
|
||||
bool newGarrisonComesFromVisiting = g && g == t->visitingHero;
|
||||
@ -656,7 +654,7 @@ DLL_LINKAGE void SetHeroesInTown::applyGs(CGameState *gs)
|
||||
}
|
||||
}
|
||||
|
||||
DLL_LINKAGE void HeroRecruited::applyGs(CGameState *gs)
|
||||
DLL_LINKAGE void HeroRecruited::applyGs(CGameState * gs) const
|
||||
{
|
||||
assert(vstd::contains(gs->hpool.heroesPool, hid));
|
||||
CGHeroInstance *h = gs->hpool.heroesPool[hid];
|
||||
@ -676,14 +674,14 @@ DLL_LINKAGE void HeroRecruited::applyGs(CGameState *gs)
|
||||
gs->hpool.heroesPool.erase(hid);
|
||||
if(h->id == ObjectInstanceID())
|
||||
{
|
||||
h->id = ObjectInstanceID((si32)gs->map->objects.size());
|
||||
gs->map->objects.push_back(h);
|
||||
h->id = ObjectInstanceID(static_cast<si32>(gs->map->objects.size()));
|
||||
gs->map->objects.emplace_back(h);
|
||||
}
|
||||
else
|
||||
gs->map->objects[h->id.getNum()] = h;
|
||||
|
||||
gs->map->heroesOnMap.push_back(h);
|
||||
p->heroes.push_back(h);
|
||||
gs->map->heroesOnMap.emplace_back(h);
|
||||
p->heroes.emplace_back(h);
|
||||
h->attachTo(*p);
|
||||
if(fresh)
|
||||
{
|
||||
@ -697,7 +695,7 @@ DLL_LINKAGE void HeroRecruited::applyGs(CGameState *gs)
|
||||
}
|
||||
}
|
||||
|
||||
DLL_LINKAGE void GiveHero::applyGs(CGameState *gs)
|
||||
DLL_LINKAGE void GiveHero::applyGs(CGameState * gs) const
|
||||
{
|
||||
CGHeroInstance *h = gs->getHero(id);
|
||||
|
||||
@ -712,8 +710,8 @@ DLL_LINKAGE void GiveHero::applyGs(CGameState *gs)
|
||||
h->setOwner(player);
|
||||
h->movement = h->maxMovePoints(true);
|
||||
h->pos = h->convertFromVisitablePos(oldVisitablePos);
|
||||
gs->map->heroesOnMap.push_back(h);
|
||||
gs->getPlayerState(h->getOwner())->heroes.push_back(h);
|
||||
gs->map->heroesOnMap.emplace_back(h);
|
||||
gs->getPlayerState(h->getOwner())->heroes.emplace_back(h);
|
||||
|
||||
gs->map->addBlockVisTiles(h);
|
||||
h->inTownGarrison = false;
|
||||
@ -750,9 +748,10 @@ DLL_LINKAGE void NewObject::applyGs(CGameState *gs)
|
||||
o = new CGCreature();
|
||||
{
|
||||
//CStackInstance hlp;
|
||||
CGCreature *cre = static_cast<CGCreature*>(o);
|
||||
auto * cre = dynamic_cast<CGCreature *>(o);
|
||||
//cre->slots[0] = hlp;
|
||||
cre->notGrowingTeam = cre->neverFlees = 0;
|
||||
assert(cre);
|
||||
cre->notGrowingTeam = cre->neverFlees = false;
|
||||
cre->character = 2;
|
||||
cre->gainedArtifact = ArtifactID::NONE;
|
||||
cre->identifier = -1;
|
||||
@ -767,9 +766,9 @@ DLL_LINKAGE void NewObject::applyGs(CGameState *gs)
|
||||
o->subID = subID;
|
||||
o->pos = pos;
|
||||
o->appearance = VLC->objtypeh->getHandlerFor(o->ID, o->subID)->getTemplates(terrainType).front();
|
||||
id = o->id = ObjectInstanceID((si32)gs->map->objects.size());
|
||||
id = o->id = ObjectInstanceID(static_cast<si32>(gs->map->objects.size()));
|
||||
|
||||
gs->map->objects.push_back(o);
|
||||
gs->map->objects.emplace_back(o);
|
||||
gs->map->addBlockVisTiles(o);
|
||||
o->initObj(gs->getRandomGenerator());
|
||||
gs->map->calculateGuardingGreaturePositions();
|
||||
@ -784,7 +783,7 @@ DLL_LINKAGE void NewArtifact::applyGs(CGameState *gs)
|
||||
|
||||
assert(!art->getParentNodes().size());
|
||||
art->setType(art->artType);
|
||||
if (CCombinedArtifactInstance* cart = dynamic_cast<CCombinedArtifactInstance*>(art.get()))
|
||||
if(auto * cart = dynamic_cast<CCombinedArtifactInstance *>(art.get()))
|
||||
cart->createConstituents();
|
||||
}
|
||||
|
||||
@ -834,7 +833,7 @@ DLL_LINKAGE const CArmedInstance * ArtifactLocation::relatedObj() const
|
||||
|
||||
DLL_LINKAGE PlayerColor ArtifactLocation::owningPlayer() const
|
||||
{
|
||||
auto obj = relatedObj();
|
||||
const auto * obj = relatedObj();
|
||||
return obj ? obj->tempOwner : PlayerColor::NEUTRAL;
|
||||
}
|
||||
|
||||
@ -850,7 +849,7 @@ DLL_LINKAGE CBonusSystemNode *ArtifactLocation::getHolderNode()
|
||||
|
||||
DLL_LINKAGE const CArtifactInstance *ArtifactLocation::getArt() const
|
||||
{
|
||||
auto s = getSlot();
|
||||
const auto * s = getSlot();
|
||||
if(s)
|
||||
return s->getArt();
|
||||
else
|
||||
@ -859,13 +858,13 @@ DLL_LINKAGE const CArtifactInstance *ArtifactLocation::getArt() const
|
||||
|
||||
DLL_LINKAGE const CArtifactSet * ArtifactLocation::getHolderArtSet() const
|
||||
{
|
||||
ArtifactLocation *t = const_cast<ArtifactLocation*>(this);
|
||||
auto * t = const_cast<ArtifactLocation *>(this);
|
||||
return t->getHolderArtSet();
|
||||
}
|
||||
|
||||
DLL_LINKAGE const CBonusSystemNode * ArtifactLocation::getHolderNode() const
|
||||
{
|
||||
ArtifactLocation *t = const_cast<ArtifactLocation*>(this);
|
||||
auto * t = const_cast<ArtifactLocation *>(this);
|
||||
return t->getHolderNode();
|
||||
}
|
||||
|
||||
@ -882,7 +881,7 @@ DLL_LINKAGE const ArtSlotInfo *ArtifactLocation::getSlot() const
|
||||
|
||||
DLL_LINKAGE void ChangeStackCount::applyGs(CGameState * gs)
|
||||
{
|
||||
auto srcObj = gs->getArmyInstance(army);
|
||||
auto * srcObj = gs->getArmyInstance(army);
|
||||
if(!srcObj)
|
||||
logNetwork->error("[CRITICAL] ChangeStackCount: invalid army object %d, possible game state corruption.", army.getNum());
|
||||
|
||||
@ -894,7 +893,7 @@ DLL_LINKAGE void ChangeStackCount::applyGs(CGameState * gs)
|
||||
|
||||
DLL_LINKAGE void SetStackType::applyGs(CGameState * gs)
|
||||
{
|
||||
auto srcObj = gs->getArmyInstance(army);
|
||||
auto * srcObj = gs->getArmyInstance(army);
|
||||
if(!srcObj)
|
||||
logNetwork->error("[CRITICAL] SetStackType: invalid army object %d, possible game state corruption.", army.getNum());
|
||||
|
||||
@ -903,7 +902,7 @@ DLL_LINKAGE void SetStackType::applyGs(CGameState * gs)
|
||||
|
||||
DLL_LINKAGE void EraseStack::applyGs(CGameState * gs)
|
||||
{
|
||||
auto srcObj = gs->getArmyInstance(army);
|
||||
auto * srcObj = gs->getArmyInstance(army);
|
||||
if(!srcObj)
|
||||
logNetwork->error("[CRITICAL] EraseStack: invalid army object %d, possible game state corruption.", army.getNum());
|
||||
|
||||
@ -912,11 +911,11 @@ DLL_LINKAGE void EraseStack::applyGs(CGameState * gs)
|
||||
|
||||
DLL_LINKAGE void SwapStacks::applyGs(CGameState * gs)
|
||||
{
|
||||
auto srcObj = gs->getArmyInstance(srcArmy);
|
||||
auto * srcObj = gs->getArmyInstance(srcArmy);
|
||||
if(!srcObj)
|
||||
logNetwork->error("[CRITICAL] SwapStacks: invalid army object %d, possible game state corruption.", srcArmy.getNum());
|
||||
|
||||
auto dstObj = gs->getArmyInstance(dstArmy);
|
||||
auto * dstObj = gs->getArmyInstance(dstArmy);
|
||||
if(!dstObj)
|
||||
logNetwork->error("[CRITICAL] SwapStacks: invalid army object %d, possible game state corruption.", dstArmy.getNum());
|
||||
|
||||
@ -929,7 +928,7 @@ DLL_LINKAGE void SwapStacks::applyGs(CGameState * gs)
|
||||
|
||||
DLL_LINKAGE void InsertNewStack::applyGs(CGameState *gs)
|
||||
{
|
||||
if(auto obj = gs->getArmyInstance(army))
|
||||
if(auto * obj = gs->getArmyInstance(army))
|
||||
obj->putStack(slot, new CStackInstance(type, count));
|
||||
else
|
||||
logNetwork->error("[CRITICAL] InsertNewStack: invalid army object %d, possible game state corruption.", army.getNum());
|
||||
@ -937,11 +936,11 @@ DLL_LINKAGE void InsertNewStack::applyGs(CGameState *gs)
|
||||
|
||||
DLL_LINKAGE void RebalanceStacks::applyGs(CGameState * gs)
|
||||
{
|
||||
auto srcObj = gs->getArmyInstance(srcArmy);
|
||||
auto * srcObj = gs->getArmyInstance(srcArmy);
|
||||
if(!srcObj)
|
||||
logNetwork->error("[CRITICAL] RebalanceStacks: invalid army object %d, possible game state corruption.", srcArmy.getNum());
|
||||
|
||||
auto dstObj = gs->getArmyInstance(dstArmy);
|
||||
auto * dstObj = gs->getArmyInstance(dstArmy);
|
||||
if(!dstObj)
|
||||
logNetwork->error("[CRITICAL] RebalanceStacks: invalid army object %d, possible game state corruption.", dstArmy.getNum());
|
||||
|
||||
@ -960,13 +959,13 @@ DLL_LINKAGE void RebalanceStacks::applyGs(CGameState * gs)
|
||||
MAYBE_UNUSED(c);
|
||||
auto alHere = ArtifactLocation (src.getStack(), ArtifactPosition::CREATURE_SLOT);
|
||||
auto alDest = ArtifactLocation (dst.getStack(), ArtifactPosition::CREATURE_SLOT);
|
||||
auto artHere = alHere.getArt();
|
||||
auto artDest = alDest.getArt();
|
||||
auto * artHere = alHere.getArt();
|
||||
auto * artDest = alDest.getArt();
|
||||
if (artHere)
|
||||
{
|
||||
if (alDest.getArt())
|
||||
{
|
||||
auto hero = dynamic_cast <CGHeroInstance *>(src.army.get());
|
||||
auto * hero = dynamic_cast<CGHeroInstance *>(src.army.get());
|
||||
if (hero)
|
||||
{
|
||||
artDest->move (alDest, ArtifactLocation (hero, alDest.getArt()->firstBackpackSlot (hero)));
|
||||
@ -1058,13 +1057,13 @@ DLL_LINKAGE void PutArtifact::applyGs(CGameState *gs)
|
||||
|
||||
DLL_LINKAGE void EraseArtifact::applyGs(CGameState *gs)
|
||||
{
|
||||
auto slot = al.getSlot();
|
||||
const auto * slot = al.getSlot();
|
||||
if(slot->locked)
|
||||
{
|
||||
logGlobal->debug("Erasing locked artifact: %s", slot->artifact->artType->getNameTranslated());
|
||||
DisassembledArtifact dis;
|
||||
dis.al.artHolder = al.artHolder;
|
||||
auto aset = al.getHolderArtSet();
|
||||
auto * aset = al.getHolderArtSet();
|
||||
#ifndef NDEBUG
|
||||
bool found = false;
|
||||
#endif
|
||||
@ -1123,9 +1122,9 @@ DLL_LINKAGE void BulkMoveArtifacts::applyGs(CGameState * gs)
|
||||
{
|
||||
srcPos = ArtifactPosition(srcPos.num - numBackpackArtifactsMoved);
|
||||
}
|
||||
auto slotInfo = artSet->getSlot(srcPos);
|
||||
const auto * slotInfo = artSet->getSlot(srcPos);
|
||||
assert(slotInfo);
|
||||
auto art = const_cast<CArtifactInstance*>(slotInfo->getArt());
|
||||
auto * art = const_cast<CArtifactInstance *>(slotInfo->getArt());
|
||||
assert(art);
|
||||
switch(operation)
|
||||
{
|
||||
@ -1153,8 +1152,8 @@ DLL_LINKAGE void BulkMoveArtifacts::applyGs(CGameState * gs)
|
||||
if(swap)
|
||||
{
|
||||
// Swap
|
||||
auto leftSet = getSrcHolderArtSet();
|
||||
auto rightSet = getDstHolderArtSet();
|
||||
auto * leftSet = getSrcHolderArtSet();
|
||||
auto * rightSet = getDstHolderArtSet();
|
||||
CArtifactFittingSet artFittingSet(leftSet->bearerType());
|
||||
|
||||
artFittingSet.artifactsWorn = rightSet->artifactsWorn;
|
||||
@ -1182,7 +1181,7 @@ DLL_LINKAGE void AssembledArtifact::applyGs(CGameState *gs)
|
||||
}));
|
||||
MAYBE_UNUSED(transformedArt);
|
||||
|
||||
auto combinedArt = new CCombinedArtifactInstance(builtArt);
|
||||
auto * combinedArt = new CCombinedArtifactInstance(builtArt);
|
||||
gs->map->addNewArtifactInstance(combinedArt);
|
||||
// Retrieve all constituents
|
||||
for(const CArtifact * constituent : *builtArt->constituents)
|
||||
@ -1213,7 +1212,7 @@ DLL_LINKAGE void AssembledArtifact::applyGs(CGameState *gs)
|
||||
|
||||
DLL_LINKAGE void DisassembledArtifact::applyGs(CGameState *gs)
|
||||
{
|
||||
CCombinedArtifactInstance *disassembled = dynamic_cast<CCombinedArtifactInstance*>(al.getArt());
|
||||
auto * disassembled = dynamic_cast<CCombinedArtifactInstance *>(al.getArt());
|
||||
assert(disassembled);
|
||||
|
||||
std::vector<CCombinedArtifactInstance::ConstituentInfo> constituents = disassembled->constituentsInfo;
|
||||
@ -1233,11 +1232,11 @@ DLL_LINKAGE void HeroVisit::applyGs(CGameState *gs)
|
||||
{
|
||||
}
|
||||
|
||||
DLL_LINKAGE void SetAvailableArtifacts::applyGs(CGameState *gs)
|
||||
DLL_LINKAGE void SetAvailableArtifacts::applyGs(CGameState * gs) const
|
||||
{
|
||||
if(id >= 0)
|
||||
{
|
||||
if(CGBlackMarket *bm = dynamic_cast<CGBlackMarket*>(gs->map->objects[id].get()))
|
||||
if(auto * bm = dynamic_cast<CGBlackMarket *>(gs->map->objects[id].get()))
|
||||
{
|
||||
bm->artifacts = arts;
|
||||
}
|
||||
@ -1262,7 +1261,7 @@ DLL_LINKAGE void NewTurn::applyGs(CGameState *gs)
|
||||
gs->globalEffects.reduceBonusDurations(Bonus::OneWeek);
|
||||
//TODO not really a single root hierarchy, what about bonuses placed elsewhere? [not an issue with H3 mechanics but in the future...]
|
||||
|
||||
for(NewTurn::Hero h : heroes) //give mana/movement point
|
||||
for(const NewTurn::Hero & h : heroes) //give mana/movement point
|
||||
{
|
||||
CGHeroInstance *hero = gs->getHero(h.id);
|
||||
if(!hero)
|
||||
@ -1286,13 +1285,13 @@ DLL_LINKAGE void NewTurn::applyGs(CGameState *gs)
|
||||
hero->mana = h.mana;
|
||||
}
|
||||
|
||||
for(auto i = res.cbegin(); i != res.cend(); i++)
|
||||
for(const auto & re : res)
|
||||
{
|
||||
assert(i->first < PlayerColor::PLAYER_LIMIT);
|
||||
gs->getPlayerState(i->first)->resources = i->second;
|
||||
gs->getPlayerState(re.first)->resources = re.second;
|
||||
}
|
||||
|
||||
for(auto creatureSet : cres) //set available creatures in towns
|
||||
for(const auto & creatureSet : cres) //set available creatures in towns
|
||||
creatureSet.second.applyGs(gs);
|
||||
|
||||
for(CGTownInstance* t : gs->map->towns)
|
||||
@ -1322,7 +1321,7 @@ DLL_LINKAGE void NewTurn::applyGs(CGameState *gs)
|
||||
}
|
||||
}
|
||||
|
||||
DLL_LINKAGE void SetObjectProperty::applyGs(CGameState *gs)
|
||||
DLL_LINKAGE void SetObjectProperty::applyGs(CGameState * gs) const
|
||||
{
|
||||
CGObjectInstance *obj = gs->getObjInstance(id);
|
||||
if(!obj)
|
||||
@ -1331,18 +1330,19 @@ DLL_LINKAGE void SetObjectProperty::applyGs(CGameState *gs)
|
||||
return;
|
||||
}
|
||||
|
||||
CArmedInstance *cai = dynamic_cast<CArmedInstance *>(obj);
|
||||
auto * cai = dynamic_cast<CArmedInstance *>(obj);
|
||||
if(what == ObjProperty::OWNER && cai)
|
||||
{
|
||||
if(obj->ID == Obj::TOWN)
|
||||
{
|
||||
CGTownInstance *t = static_cast<CGTownInstance*>(obj);
|
||||
auto * t = dynamic_cast<CGTownInstance *>(obj);
|
||||
assert(t);
|
||||
if(t->tempOwner < PlayerColor::PLAYER_LIMIT)
|
||||
gs->getPlayerState(t->tempOwner)->towns -= t;
|
||||
if(val < PlayerColor::PLAYER_LIMIT_I)
|
||||
{
|
||||
PlayerState * p = gs->getPlayerState(PlayerColor(val));
|
||||
p->towns.push_back(t);
|
||||
p->towns.emplace_back(t);
|
||||
|
||||
//reset counter before NewTurn to avoid no town message if game loaded at turn when one already captured
|
||||
if(p->daysWithoutCastle)
|
||||
@ -1363,7 +1363,7 @@ DLL_LINKAGE void SetObjectProperty::applyGs(CGameState *gs)
|
||||
|
||||
DLL_LINKAGE void PrepareHeroLevelUp::applyGs(CGameState * gs)
|
||||
{
|
||||
auto hero = gs->getHero(heroId);
|
||||
auto * hero = gs->getHero(heroId);
|
||||
assert(hero);
|
||||
|
||||
auto proposedSkills = hero->getLevelUpProposedSecondarySkills();
|
||||
@ -1378,39 +1378,39 @@ DLL_LINKAGE void PrepareHeroLevelUp::applyGs(CGameState * gs)
|
||||
}
|
||||
}
|
||||
|
||||
DLL_LINKAGE void HeroLevelUp::applyGs(CGameState * gs)
|
||||
DLL_LINKAGE void HeroLevelUp::applyGs(CGameState * gs) const
|
||||
{
|
||||
auto hero = gs->getHero(heroId);
|
||||
auto * hero = gs->getHero(heroId);
|
||||
assert(hero);
|
||||
hero->levelUp(skills);
|
||||
}
|
||||
|
||||
DLL_LINKAGE void CommanderLevelUp::applyGs(CGameState * gs)
|
||||
DLL_LINKAGE void CommanderLevelUp::applyGs(CGameState * gs) const
|
||||
{
|
||||
auto hero = gs->getHero(heroId);
|
||||
auto * hero = gs->getHero(heroId);
|
||||
assert(hero);
|
||||
auto commander = hero->commander;
|
||||
assert(commander);
|
||||
commander->levelUp();
|
||||
}
|
||||
|
||||
DLL_LINKAGE void BattleStart::applyGs(CGameState *gs)
|
||||
DLL_LINKAGE void BattleStart::applyGs(CGameState * gs) const
|
||||
{
|
||||
gs->curB = info;
|
||||
gs->curB->localInit();
|
||||
}
|
||||
|
||||
DLL_LINKAGE void BattleNextRound::applyGs(CGameState *gs)
|
||||
DLL_LINKAGE void BattleNextRound::applyGs(CGameState * gs) const
|
||||
{
|
||||
gs->curB->nextRound(round);
|
||||
}
|
||||
|
||||
DLL_LINKAGE void BattleSetActiveStack::applyGs(CGameState *gs)
|
||||
DLL_LINKAGE void BattleSetActiveStack::applyGs(CGameState * gs) const
|
||||
{
|
||||
gs->curB->nextTurn(stack);
|
||||
}
|
||||
|
||||
DLL_LINKAGE void BattleTriggerEffect::applyGs(CGameState *gs)
|
||||
DLL_LINKAGE void BattleTriggerEffect::applyGs(CGameState * gs) const
|
||||
{
|
||||
CStack * st = gs->curB->getStack(stackID);
|
||||
assert(st);
|
||||
@ -1448,7 +1448,7 @@ DLL_LINKAGE void BattleTriggerEffect::applyGs(CGameState *gs)
|
||||
}
|
||||
}
|
||||
|
||||
DLL_LINKAGE void BattleUpdateGateState::applyGs(CGameState *gs)
|
||||
DLL_LINKAGE void BattleUpdateGateState::applyGs(CGameState * gs) const
|
||||
{
|
||||
if(gs->curB)
|
||||
gs->curB->si.gateState = state;
|
||||
@ -1462,7 +1462,7 @@ void BattleResult::applyGs(CGameState *gs)
|
||||
|
||||
for(int i = 0; i < 2; ++i)
|
||||
{
|
||||
if(auto h = gs->curB->battleGetFightingHero(i))
|
||||
if(auto * h = gs->curB->battleGetFightingHero(i))
|
||||
{
|
||||
h->removeBonusesRecursive(Bonus::OneBattle); //remove any "until next battle" bonuses
|
||||
if (h->commander && h->commander->alive)
|
||||
@ -1556,7 +1556,7 @@ DLL_LINKAGE void StartAction::applyGs(CGameState *gs)
|
||||
}
|
||||
else
|
||||
{
|
||||
gs->curB->sides[ba.side].usedSpellsHistory.push_back(SpellID(ba.actionSubtype));
|
||||
gs->curB->sides[ba.side].usedSpellsHistory.emplace_back(ba.actionSubtype);
|
||||
}
|
||||
|
||||
switch(ba.actionType)
|
||||
@ -1581,7 +1581,7 @@ DLL_LINKAGE void StartAction::applyGs(CGameState *gs)
|
||||
}
|
||||
}
|
||||
|
||||
DLL_LINKAGE void BattleSpellCast::applyGs(CGameState *gs)
|
||||
DLL_LINKAGE void BattleSpellCast::applyGs(CGameState * gs) const
|
||||
{
|
||||
assert(gs->curB);
|
||||
|
||||
@ -1647,7 +1647,7 @@ DLL_LINKAGE void BattleUnitsChanged::applyBattle(IBattleState * battleState)
|
||||
battleState->updateUnit(elem.id, elem.data);
|
||||
break;
|
||||
default:
|
||||
logNetwork->error("Unknown unit operation %d", (int)elem.operation);
|
||||
logNetwork->error("Unknown unit operation %d", static_cast<int>(elem.operation));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1676,20 +1676,15 @@ DLL_LINKAGE void BattleObstaclesChanged::applyBattle(IBattleState * battleState)
|
||||
battleState->updateObstacle(change);
|
||||
break;
|
||||
default:
|
||||
logNetwork->error("Unknown obstacle operation %d", (int)change.operation);
|
||||
logNetwork->error("Unknown obstacle operation %d", static_cast<int>(change.operation));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DLL_LINKAGE CatapultAttack::CatapultAttack()
|
||||
{
|
||||
attacker = -1;
|
||||
}
|
||||
DLL_LINKAGE CatapultAttack::CatapultAttack() = default;
|
||||
|
||||
DLL_LINKAGE CatapultAttack::~CatapultAttack()
|
||||
{
|
||||
}
|
||||
DLL_LINKAGE CatapultAttack::~CatapultAttack() = default;
|
||||
|
||||
DLL_LINKAGE void CatapultAttack::applyGs(CGameState * gs)
|
||||
{
|
||||
@ -1699,7 +1694,7 @@ DLL_LINKAGE void CatapultAttack::applyGs(CGameState * gs)
|
||||
|
||||
DLL_LINKAGE void CatapultAttack::applyBattle(IBattleState * battleState)
|
||||
{
|
||||
auto town = battleState->getDefendedTown();
|
||||
const auto * town = battleState->getDefendedTown();
|
||||
if(!town)
|
||||
return;
|
||||
|
||||
@ -1713,7 +1708,7 @@ DLL_LINKAGE void CatapultAttack::applyBattle(IBattleState * battleState)
|
||||
}
|
||||
}
|
||||
|
||||
DLL_LINKAGE void BattleSetStackProperty::applyGs(CGameState * gs)
|
||||
DLL_LINKAGE void BattleSetStackProperty::applyGs(CGameState * gs) const
|
||||
{
|
||||
CStack * stack = gs->curB->getStack(stackID);
|
||||
switch(which)
|
||||
@ -1754,7 +1749,7 @@ DLL_LINKAGE void BattleSetStackProperty::applyGs(CGameState * gs)
|
||||
}
|
||||
}
|
||||
|
||||
DLL_LINKAGE void PlayerCheated::applyGs(CGameState *gs)
|
||||
DLL_LINKAGE void PlayerCheated::applyGs(CGameState * gs) const
|
||||
{
|
||||
if(!player.isValidPlayer())
|
||||
return;
|
||||
@ -1763,7 +1758,7 @@ DLL_LINKAGE void PlayerCheated::applyGs(CGameState *gs)
|
||||
gs->getPlayerState(player)->enteredWinningCheatCode = winningCheatCode;
|
||||
}
|
||||
|
||||
DLL_LINKAGE void YourTurn::applyGs(CGameState *gs)
|
||||
DLL_LINKAGE void YourTurn::applyGs(CGameState * gs) const
|
||||
{
|
||||
gs->currentPlayer = player;
|
||||
|
||||
@ -1771,8 +1766,10 @@ DLL_LINKAGE void YourTurn::applyGs(CGameState *gs)
|
||||
playerState.daysWithoutCastle = daysWithoutCastle;
|
||||
}
|
||||
|
||||
DLL_LINKAGE Component::Component(const CStackBasicDescriptor &stack)
|
||||
: id(CREATURE), subtype(stack.type->idNumber), val(stack.count), when(0)
|
||||
DLL_LINKAGE Component::Component(const CStackBasicDescriptor & stack)
|
||||
: id(CREATURE)
|
||||
, subtype(stack.type->idNumber)
|
||||
, val(stack.count)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -63,14 +63,10 @@ struct LobbyClientConnected : public CLobbyPackToPropagate
|
||||
// Set by client before sending pack to server
|
||||
std::string uuid;
|
||||
std::vector<std::string> names;
|
||||
StartInfo::EMode mode;
|
||||
StartInfo::EMode mode = StartInfo::INVALID;
|
||||
// Changed by server before announcing pack
|
||||
int clientId;
|
||||
int hostClientId;
|
||||
|
||||
LobbyClientConnected()
|
||||
: mode(StartInfo::INVALID), clientId(-1), hostClientId(-1)
|
||||
{}
|
||||
int clientId = -1;
|
||||
int hostClientId = -1;
|
||||
|
||||
bool checkClientPermissions(CVCMIServer * srv) const;
|
||||
bool applyOnLobbyHandler(CServerHandler * handler);
|
||||
@ -92,9 +88,8 @@ struct LobbyClientConnected : public CLobbyPackToPropagate
|
||||
struct LobbyClientDisconnected : public CLobbyPackToPropagate
|
||||
{
|
||||
int clientId;
|
||||
bool shutdownServer;
|
||||
bool shutdownServer = false;
|
||||
|
||||
LobbyClientDisconnected() : shutdownServer(false) {}
|
||||
bool checkClientPermissions(CVCMIServer * srv) const;
|
||||
bool applyOnServer(CVCMIServer * srv);
|
||||
void applyOnServerAfterAnnounce(CVCMIServer * srv);
|
||||
@ -126,9 +121,8 @@ struct LobbyGuiAction : public CLobbyPackToPropagate
|
||||
{
|
||||
enum EAction : ui8 {
|
||||
NONE, NO_TAB, OPEN_OPTIONS, OPEN_SCENARIO_LIST, OPEN_RANDOM_MAP_OPTIONS
|
||||
} action;
|
||||
} action = NONE;
|
||||
|
||||
LobbyGuiAction() : action(NONE) {}
|
||||
bool checkClientPermissions(CVCMIServer * srv) const;
|
||||
void applyOnLobbyScreen(CLobbyScreen * lobby, CServerHandler * handler);
|
||||
|
||||
@ -157,11 +151,10 @@ struct LobbyEndGame : public CLobbyPackToPropagate
|
||||
struct LobbyStartGame : public CLobbyPackToPropagate
|
||||
{
|
||||
// Set by server
|
||||
std::shared_ptr<StartInfo> initializedStartInfo;
|
||||
CGameState * initializedGameState;
|
||||
int clientId; //-1 means to all clients
|
||||
std::shared_ptr<StartInfo> initializedStartInfo = nullptr;
|
||||
CGameState * initializedGameState = nullptr;
|
||||
int clientId = -1; //-1 means to all clients
|
||||
|
||||
LobbyStartGame() : initializedStartInfo(nullptr), initializedGameState(nullptr), clientId(-1) {}
|
||||
bool checkClientPermissions(CVCMIServer * srv) const;
|
||||
bool applyOnServer(CVCMIServer * srv);
|
||||
void applyOnServerAfterAnnounce(CVCMIServer * srv);
|
||||
@ -181,9 +174,8 @@ struct LobbyStartGame : public CLobbyPackToPropagate
|
||||
|
||||
struct LobbyChangeHost : public CLobbyPackToPropagate
|
||||
{
|
||||
int newHostConnectionId;
|
||||
int newHostConnectionId = -1;
|
||||
|
||||
LobbyChangeHost() : newHostConnectionId(-1) {}
|
||||
bool checkClientPermissions(CVCMIServer * srv) const;
|
||||
bool applyOnServer(CVCMIServer * srv);
|
||||
bool applyOnServerAfterAnnounce(CVCMIServer * srv);
|
||||
@ -197,9 +189,8 @@ struct LobbyChangeHost : public CLobbyPackToPropagate
|
||||
struct LobbyUpdateState : public CLobbyPackToPropagate
|
||||
{
|
||||
LobbyState state;
|
||||
bool hostChanged; // Used on client-side only
|
||||
bool hostChanged = false; // Used on client-side only
|
||||
|
||||
LobbyUpdateState() : hostChanged(false) {}
|
||||
bool applyOnLobbyHandler(CServerHandler * handler);
|
||||
void applyOnLobbyScreen(CLobbyScreen * lobby, CServerHandler * handler);
|
||||
|
||||
@ -228,7 +219,6 @@ struct LobbySetCampaign : public CLobbyPackToServer
|
||||
{
|
||||
std::shared_ptr<CCampaignState> ourCampaign;
|
||||
|
||||
LobbySetCampaign() {}
|
||||
bool applyOnServer(CVCMIServer * srv);
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
@ -239,9 +229,8 @@ struct LobbySetCampaign : public CLobbyPackToServer
|
||||
|
||||
struct LobbySetCampaignMap : public CLobbyPackToServer
|
||||
{
|
||||
int mapId;
|
||||
int mapId = -1;
|
||||
|
||||
LobbySetCampaignMap() : mapId(-1) {}
|
||||
bool applyOnServer(CVCMIServer * srv);
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
@ -252,9 +241,8 @@ struct LobbySetCampaignMap : public CLobbyPackToServer
|
||||
|
||||
struct LobbySetCampaignBonus : public CLobbyPackToServer
|
||||
{
|
||||
int bonusId;
|
||||
int bonusId = -1;
|
||||
|
||||
LobbySetCampaignBonus() : bonusId(-1) {}
|
||||
bool applyOnServer(CVCMIServer * srv);
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
@ -266,11 +254,10 @@ struct LobbySetCampaignBonus : public CLobbyPackToServer
|
||||
struct LobbyChangePlayerOption : public CLobbyPackToServer
|
||||
{
|
||||
enum EWhat : ui8 {UNKNOWN, TOWN, HERO, BONUS};
|
||||
ui8 what;
|
||||
si8 direction; //-1 or +1
|
||||
PlayerColor color;
|
||||
ui8 what = UNKNOWN;
|
||||
si8 direction = 0; //-1 or +1
|
||||
PlayerColor color = PlayerColor::CANNOT_DETERMINE;
|
||||
|
||||
LobbyChangePlayerOption() : what(UNKNOWN), direction(0), color(PlayerColor::CANNOT_DETERMINE) {}
|
||||
bool checkClientPermissions(CVCMIServer * srv) const;
|
||||
bool applyOnServer(CVCMIServer * srv);
|
||||
|
||||
@ -284,9 +271,8 @@ struct LobbyChangePlayerOption : public CLobbyPackToServer
|
||||
|
||||
struct LobbySetPlayer : public CLobbyPackToServer
|
||||
{
|
||||
PlayerColor clickedColor;
|
||||
PlayerColor clickedColor = PlayerColor::CANNOT_DETERMINE;
|
||||
|
||||
LobbySetPlayer() : clickedColor(PlayerColor::CANNOT_DETERMINE){}
|
||||
bool applyOnServer(CVCMIServer * srv);
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
@ -297,9 +283,8 @@ struct LobbySetPlayer : public CLobbyPackToServer
|
||||
|
||||
struct LobbySetTurnTime : public CLobbyPackToServer
|
||||
{
|
||||
ui8 turnTime;
|
||||
ui8 turnTime = 0;
|
||||
|
||||
LobbySetTurnTime() : turnTime(0) {}
|
||||
bool applyOnServer(CVCMIServer * srv);
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
@ -310,9 +295,8 @@ struct LobbySetTurnTime : public CLobbyPackToServer
|
||||
|
||||
struct LobbySetDifficulty : public CLobbyPackToServer
|
||||
{
|
||||
ui8 difficulty;
|
||||
ui8 difficulty = 0;
|
||||
|
||||
LobbySetDifficulty() : difficulty(0) {}
|
||||
bool applyOnServer(CVCMIServer * srv);
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
@ -323,10 +307,9 @@ struct LobbySetDifficulty : public CLobbyPackToServer
|
||||
|
||||
struct LobbyForceSetPlayer : public CLobbyPackToServer
|
||||
{
|
||||
ui8 targetConnectedPlayer;
|
||||
PlayerColor targetPlayerColor;
|
||||
ui8 targetConnectedPlayer = -1;
|
||||
PlayerColor targetPlayerColor = PlayerColor::CANNOT_DETERMINE;
|
||||
|
||||
LobbyForceSetPlayer() : targetConnectedPlayer(-1), targetPlayerColor(PlayerColor::CANNOT_DETERMINE) {}
|
||||
bool applyOnServer(CVCMIServer * srv);
|
||||
|
||||
template <typename Handler> void serialize(Handler & h, const int version)
|
||||
|
65
lib/int3.h
65
lib/int3.h
@ -18,48 +18,41 @@ public:
|
||||
si32 x, y, z;
|
||||
|
||||
//c-tor: x, y, z initialized to 0
|
||||
int3() : x(0), y(0), z(0) {} // I think that x, y, z should be left uninitialized.
|
||||
constexpr int3() : x(0), y(0), z(0) {} // I think that x, y, z should be left uninitialized.
|
||||
//c-tor: x, y, z initialized to i
|
||||
explicit int3(const si32 i) : x(i), y(i), z(i) {}
|
||||
explicit constexpr int3(const si32 i) : x(i), y(i), z(i) {}
|
||||
//c-tor: x, y, z initialized to X, Y, Z
|
||||
int3(const si32 X, const si32 Y, const si32 Z) : x(X), y(Y), z(Z) {}
|
||||
int3(const int3 & c) : x(c.x), y(c.y), z(c.z) {} // Should be set to default (C++11)?
|
||||
constexpr int3(const si32 X, const si32 Y, const si32 Z) : x(X), y(Y), z(Z) {}
|
||||
constexpr int3(const int3 & c) = default;
|
||||
|
||||
int3 & operator=(const int3 & c) // Should be set to default (C++11)?
|
||||
{
|
||||
x = c.x;
|
||||
y = c.y;
|
||||
z = c.z;
|
||||
constexpr int3 & operator=(const int3 & c) = default;
|
||||
constexpr int3 operator-() const { return int3(-x, -y, -z); }
|
||||
|
||||
return *this;
|
||||
}
|
||||
int3 operator-() const { return int3(-x, -y, -z); }
|
||||
|
||||
int3 operator+(const int3 & i) const { return int3(x + i.x, y + i.y, z + i.z); }
|
||||
int3 operator-(const int3 & i) const { return int3(x - i.x, y - i.y, z - i.z); }
|
||||
constexpr int3 operator+(const int3 & i) const { return int3(x + i.x, y + i.y, z + i.z); }
|
||||
constexpr int3 operator-(const int3 & i) const { return int3(x - i.x, y - i.y, z - i.z); }
|
||||
//returns int3 with coordinates increased by given number
|
||||
int3 operator+(const si32 i) const { return int3(x + i, y + i, z + i); }
|
||||
constexpr int3 operator+(const si32 i) const { return int3(x + i, y + i, z + i); }
|
||||
//returns int3 with coordinates decreased by given number
|
||||
int3 operator-(const si32 i) const { return int3(x - i, y - i, z - i); }
|
||||
constexpr int3 operator-(const si32 i) const { return int3(x - i, y - i, z - i); }
|
||||
|
||||
//returns int3 with coordinates multiplied by given number
|
||||
int3 operator*(const double i) const { return int3((int)(x * i), (int)(y * i), (int)(z * i)); }
|
||||
constexpr int3 operator*(const double i) const { return int3((int)(x * i), (int)(y * i), (int)(z * i)); }
|
||||
//returns int3 with coordinates divided by given number
|
||||
int3 operator/(const double i) const { return int3((int)(x / i), (int)(y / i), (int)(z / i)); }
|
||||
constexpr int3 operator/(const double i) const { return int3((int)(x / i), (int)(y / i), (int)(z / i)); }
|
||||
|
||||
//returns int3 with coordinates multiplied by given number
|
||||
int3 operator*(const si32 i) const { return int3(x * i, y * i, z * i); }
|
||||
constexpr int3 operator*(const si32 i) const { return int3(x * i, y * i, z * i); }
|
||||
//returns int3 with coordinates divided by given number
|
||||
int3 operator/(const si32 i) const { return int3(x / i, y / i, z / i); }
|
||||
constexpr int3 operator/(const si32 i) const { return int3(x / i, y / i, z / i); }
|
||||
|
||||
int3 & operator+=(const int3 & i)
|
||||
constexpr int3 & operator+=(const int3 & i)
|
||||
{
|
||||
x += i.x;
|
||||
y += i.y;
|
||||
z += i.z;
|
||||
return *this;
|
||||
}
|
||||
int3 & operator-=(const int3 & i)
|
||||
constexpr int3 & operator-=(const int3 & i)
|
||||
{
|
||||
x -= i.x;
|
||||
y -= i.y;
|
||||
@ -68,7 +61,7 @@ public:
|
||||
}
|
||||
|
||||
//increases all coordinates by given number
|
||||
int3 & operator+=(const si32 i)
|
||||
constexpr int3 & operator+=(const si32 i)
|
||||
{
|
||||
x += i;
|
||||
y += i;
|
||||
@ -76,7 +69,7 @@ public:
|
||||
return *this;
|
||||
}
|
||||
//decreases all coordinates by given number
|
||||
int3 & operator-=(const si32 i)
|
||||
constexpr int3 & operator-=(const si32 i)
|
||||
{
|
||||
x -= i;
|
||||
y -= i;
|
||||
@ -84,10 +77,10 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool operator==(const int3 & i) const { return (x == i.x && y == i.y && z == i.z); }
|
||||
bool operator!=(const int3 & i) const { return (x != i.x || y != i.y || z != i.z); }
|
||||
constexpr bool operator==(const int3 & i) const { return (x == i.x && y == i.y && z == i.z); }
|
||||
constexpr bool operator!=(const int3 & i) const { return (x != i.x || y != i.y || z != i.z); }
|
||||
|
||||
bool operator<(const int3 & i) const
|
||||
constexpr bool operator<(const int3 & i) const
|
||||
{
|
||||
if (z < i.z)
|
||||
return true;
|
||||
@ -130,7 +123,7 @@ public:
|
||||
}
|
||||
|
||||
//returns squared distance on Oxy plane (z coord is not used)
|
||||
ui32 dist2dSQ(const int3 & o) const
|
||||
constexpr ui32 dist2dSQ(const int3 & o) const
|
||||
{
|
||||
const si32 dx = (x - o.x);
|
||||
const si32 dy = (y - o.y);
|
||||
@ -142,17 +135,17 @@ public:
|
||||
return std::sqrt((double)dist2dSQ(o));
|
||||
}
|
||||
//manhattan distance used for patrol radius (z coord is not used)
|
||||
double mandist2d(const int3 & o) const
|
||||
constexpr double mandist2d(const int3 & o) const
|
||||
{
|
||||
return abs(o.x - x) + abs(o.y - y);
|
||||
return vstd::abs(o.x - x) + vstd::abs(o.y - y);
|
||||
}
|
||||
//chebyshev distance used for ambient sounds (z coord is not used)
|
||||
double chebdist2d(const int3 & o) const
|
||||
constexpr double chebdist2d(const int3 & o) const
|
||||
{
|
||||
return std::max(std::abs(o.x - x), std::abs(o.y - y));
|
||||
return std::max(vstd::abs(o.x - x), vstd::abs(o.y - y));
|
||||
}
|
||||
|
||||
bool areNeighbours(const int3 & o) const
|
||||
constexpr bool areNeighbours(const int3 & o) const
|
||||
{
|
||||
return (dist2dSQ(o) < 4) && (z == o.z);
|
||||
}
|
||||
@ -169,7 +162,7 @@ public:
|
||||
return result;
|
||||
}
|
||||
|
||||
bool valid() const //Should be named "isValid"?
|
||||
constexpr bool valid() const //Should be named "isValid"?
|
||||
{
|
||||
return z >= 0; //minimal condition that needs to be fulfilled for tiles in the map
|
||||
}
|
||||
@ -182,7 +175,7 @@ public:
|
||||
h & z;
|
||||
}
|
||||
|
||||
static std::array<int3, 8> getDirs()
|
||||
constexpr static std::array<int3, 8> getDirs()
|
||||
{
|
||||
return { { int3(0,1,0),int3(0,-1,0),int3(-1,0,0),int3(+1,0,0),
|
||||
int3(1,1,0),int3(-1,1,0),int3(1,-1,0),int3(-1,-1,0) } };
|
||||
|
@ -81,8 +81,8 @@ void CRandomRewardObjectInfo::configureLimiter(CRewardableObject * object, CRand
|
||||
|
||||
limiter.primary = JsonRandom::loadPrimary(source["primary"], rng);
|
||||
limiter.secondary = JsonRandom::loadSecondary(source["secondary"], rng);
|
||||
limiter.artifacts = JsonRandom::loadArtifacts(source["spells"], rng);
|
||||
limiter.spells = JsonRandom::loadSpells(source["artifacts"], rng, spells);
|
||||
limiter.artifacts = JsonRandom::loadArtifacts(source["artifacts"], rng);
|
||||
limiter.spells = JsonRandom::loadSpells(source["spells"], rng, spells);
|
||||
limiter.creatures = JsonRandom::loadCreatures(source["creatures"], rng);
|
||||
|
||||
limiter.allOf = configureSublimiters(object, rng, source["allOf"] );
|
||||
|
@ -241,7 +241,6 @@ bool ObjectManager::createRequiredObjects()
|
||||
for(const auto & object : requiredObjects)
|
||||
{
|
||||
auto * obj = object.first;
|
||||
int3 pos;
|
||||
rmg::Object rmgObject(*obj);
|
||||
rmgObject.setTemplate(zone.getTerrainType());
|
||||
bool guarded = addGuard(rmgObject, object.second, (obj->ID == Obj::MONOLITH_TWO_WAY));
|
||||
@ -278,7 +277,6 @@ bool ObjectManager::createRequiredObjects()
|
||||
for(const auto & object : closeObjects)
|
||||
{
|
||||
auto * obj = object.first;
|
||||
int3 pos;
|
||||
auto possibleArea = zone.areaPossible();
|
||||
rmg::Object rmgObject(*obj);
|
||||
rmgObject.setTemplate(zone.getTerrainType());
|
||||
|
@ -736,7 +736,6 @@ void TreasurePlacer::createTreasures(ObjectManager & manager)
|
||||
if(guarded)
|
||||
guarded = manager.addGuard(rmgObject, value);
|
||||
|
||||
int3 pos;
|
||||
auto possibleArea = zone.areaPossible();
|
||||
|
||||
auto path = rmg::Path::invalid();
|
||||
|
Loading…
Reference in New Issue
Block a user