1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-11 14:49:23 +02:00

Merge pull request #1194 from Nordsoft91/editor-crash

Fix hero-related problems in editor [1.1]
This commit is contained in:
Andrii Danylchenko 2022-12-04 18:19:41 +02:00 committed by GitHub
commit 35e8b794cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 4 deletions

View File

@ -1434,7 +1434,7 @@ void CGHeroInstance::serializeCommonOptions(JsonSerializeFormat & handler)
handler.serializeString("biography", biography);
handler.serializeInt("experience", exp, 0);
if (!handler.saving)
if(!handler.saving && exp != 0xffffffff) //do not gain levels if experience is not initialized
{
while (gainsLevel())
{

View File

@ -555,6 +555,9 @@ void Inspector::setProperty(CGHeroInstance * o, const QString & key, const QVari
if(key == "Name")
o->name = value.toString().toStdString();
if(key == "Experience")
o->exp = value.toInt();
if(key == "Hero type")
{
for(auto t : VLC->heroh->objects)

View File

@ -128,10 +128,15 @@ void MapController::repairMap()
assert(type->heroClass);
//TODO: find a way to get proper type name
if(obj->ID == Obj::HERO)
{
nih->typeName = "hero";
nih->subTypeName = type->heroClass->identifier;
}
if(obj->ID == Obj::PRISON)
{
nih->typeName = "prison";
nih->subTypeName = type->heroClass->identifier;
nih->subTypeName = "prison";
}
nih->type = type;
if(nih->name.empty())

View File

@ -460,8 +460,11 @@ void SelectionObjectsLayer::selectObjects(int x1, int y1, int x2, int y2)
{
for(int i = x1; i < x2; ++i)
{
for(auto & o : handler->getObjects(i, j, scene->level))
selectObject(o.obj, false); //do not inform about each object added
if(map->isInTheMap(int3(i, j, scene->level)))
{
for(auto & o : handler->getObjects(i, j, scene->level))
selectObject(o.obj, false); //do not inform about each object added
}
}
}
onSelection();