mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-04 09:42:40 +02:00
Use max ui32 value instead of -1 for NO_PATROLLING
This commit is contained in:
parent
42738e20a4
commit
ed087b7a5b
@ -1749,7 +1749,7 @@ void CGHeroInstance::serializeJsonOptions(JsonSerializeFormat & handler)
|
||||
CArmedInstance::serializeJsonOptions(handler);
|
||||
|
||||
{
|
||||
int rawPatrolRadius = NO_PATROLLING;
|
||||
ui32 rawPatrolRadius = NO_PATROLLING;
|
||||
|
||||
if(handler.saving)
|
||||
{
|
||||
@ -1760,9 +1760,9 @@ void CGHeroInstance::serializeJsonOptions(JsonSerializeFormat & handler)
|
||||
|
||||
if(!handler.saving)
|
||||
{
|
||||
patrol.patrolling = (rawPatrolRadius > NO_PATROLLING);
|
||||
patrol.patrolling = (rawPatrolRadius != NO_PATROLLING);
|
||||
patrol.initialPos = visitablePos();
|
||||
patrol.patrolRadius = (rawPatrolRadius > NO_PATROLLING) ? rawPatrolRadius : 0;
|
||||
patrol.patrolRadius = patrol.patrolling ? rawPatrolRadius : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ public:
|
||||
static constexpr si32 UNINITIALIZED_MANA = -1;
|
||||
static constexpr ui32 UNINITIALIZED_MOVEMENT = -1;
|
||||
static constexpr auto UNINITIALIZED_EXPERIENCE = std::numeric_limits<TExpType>::max();
|
||||
static inline constexpr int NO_PATROLLING = -1;
|
||||
static inline constexpr ui32 NO_PATROLLING = std::numeric_limits<ui32>::max() ;
|
||||
|
||||
//std::vector<const CArtifact*> artifacts; //hero's artifacts from bag
|
||||
//std::map<ui16, const CArtifact*> artifWorn; //map<position,artifact_id>; positions: 0 - head; 1 - shoulders; 2 - neck; 3 - right hand; 4 - left hand; 5 - torso; 6 - right ring; 7 - left ring; 8 - feet; 9 - misc1; 10 - misc2; 11 - misc3; 12 - misc4; 13 - mach1; 14 - mach2; 15 - mach3; 16 - mach4; 17 - spellbook; 18 - misc5
|
||||
|
@ -338,7 +338,7 @@ void Inspector::updateProperties(CGHeroInstance * o)
|
||||
{
|
||||
const int maxRadius = 60;
|
||||
auto * patrolDelegate = new InspectorDelegate;
|
||||
patrolDelegate->options = { {QObject::tr("No patrol"), QVariant::fromValue(-1)} };
|
||||
patrolDelegate->options = { {QObject::tr("No patrol"), QVariant::fromValue(std::numeric_limits<ui32>::max())} };
|
||||
for(int i = 0; i <= maxRadius; ++i)
|
||||
patrolDelegate->options.push_back({ QObject::tr("%1 tile(s)").arg(i), QVariant::fromValue(i) });
|
||||
auto patrolRadiusText = o->patrol.patrolling ? QObject::tr("%1 tile(s)").arg(o->patrol.patrolRadius) : QObject::tr("No patrol");
|
||||
@ -725,7 +725,7 @@ void Inspector::setProperty(CGHeroInstance * o, const QString & key, const QVari
|
||||
{
|
||||
auto radius = value.toInt();
|
||||
o->patrol.patrolRadius = radius;
|
||||
o->patrol.patrolling = radius != -1;
|
||||
o->patrol.patrolling = radius != std::numeric_limits<ui32>::max();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user