Fix restoration of droid targets for non-weapon turrets when loading savegames. Closes ticket:2737
parent
b1c962dcc4
commit
10f674077d
|
@ -2098,6 +2098,11 @@ void actionUpdateDroid(DROID *psDroid)
|
|||
case DACTION_MOVETODROIDREPAIR:
|
||||
{
|
||||
// moving to repair a droid
|
||||
if (!psDroid->psActionTarget[0])
|
||||
{
|
||||
psDroid->action = DACTION_NONE;
|
||||
return;
|
||||
}
|
||||
const int xdiff = (SDWORD)psDroid->pos.x - (SDWORD)psDroid->psActionTarget[0]->pos.x;
|
||||
const int ydiff = (SDWORD)psDroid->pos.y - (SDWORD)psDroid->psActionTarget[0]->pos.y;
|
||||
if ( xdiff*xdiff + ydiff*ydiff < REPAIR_RANGE )
|
||||
|
|
19
src/game.cpp
19
src/game.cpp
|
@ -4355,20 +4355,17 @@ static bool loadSaveDroidPointers(const QString &pFileName, DROID **ppsCurrentDr
|
|||
for (psDroid = ppsCurrentDroidLists[player]; psDroid && psDroid->id != id; psDroid = psDroid->psNext) {}
|
||||
ASSERT_OR_RETURN(false, psDroid, "Droid %d not found", id);
|
||||
|
||||
for (int j = 0; j < psDroid->numWeaps; j++)
|
||||
for (int j = 0; j < DROID_MAXWEAPS; j++)
|
||||
{
|
||||
objTrace(psDroid->id, "weapon %d, nStat %d", j, psDroid->asWeaps[j].nStat);
|
||||
if (psDroid->asWeaps[j].nStat > 0)
|
||||
if (ini.contains("actionTarget/" + QString::number(j) + "/id"))
|
||||
{
|
||||
if (ini.contains("actionTarget/" + QString::number(j) + "/id"))
|
||||
{
|
||||
int tid = ini.value("actionTarget/" + QString::number(j) + "/id", -1).toInt();
|
||||
int tplayer = ini.value("actionTarget/" + QString::number(j) + "/player", -1).toInt();
|
||||
OBJECT_TYPE ttype = (OBJECT_TYPE)ini.value("actionTarget/" + QString::number(j) + "/type", 0).toInt();
|
||||
ASSERT(tid >= 0 && tplayer >= 0, "Bad ID");
|
||||
setSaveDroidActionTarget(psDroid, getBaseObjFromData(tid, tplayer, ttype), j); // TODO optimise using tplayer and ttype
|
||||
ASSERT(psDroid->psActionTarget[j], "Failed to find action target");
|
||||
}
|
||||
int tid = ini.value("actionTarget/" + QString::number(j) + "/id", -1).toInt();
|
||||
int tplayer = ini.value("actionTarget/" + QString::number(j) + "/player", -1).toInt();
|
||||
OBJECT_TYPE ttype = (OBJECT_TYPE)ini.value("actionTarget/" + QString::number(j) + "/type", 0).toInt();
|
||||
ASSERT(tid >= 0 && tplayer >= 0, "Bad ID");
|
||||
setSaveDroidActionTarget(psDroid, getBaseObjFromData(tid, tplayer, ttype), j); // TODO optimise using tplayer and ttype
|
||||
ASSERT(psDroid->psActionTarget[j], "Failed to find action target");
|
||||
}
|
||||
}
|
||||
if (ini.contains("target/id"))
|
||||
|
|
Loading…
Reference in New Issue