Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,9 @@ void MapObject::fastAssignAllUniqueIDs()
void MapObject::setThingTemplate(const ThingTemplate *thing)
{
m_thingTemplate = thing;
m_objectName = thing->getName();
if (thing) {
Comment thread
bobtista marked this conversation as resolved.
Resolved
m_objectName = thing->getName();
}
}


Expand Down
22 changes: 10 additions & 12 deletions Generals/Code/Tools/WorldBuilder/src/CUndoable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "GameLogic/SidesList.h"
#include "W3DDevice/GameClient/HeightMap.h"
#include "Common/Debug.h"
#include "Common/ThingTemplate.h"
#include "mapobjectprops.h"
#include "ObjectOptions.h"
#include "BuildList.h"
Expand Down Expand Up @@ -346,6 +347,8 @@ MoveInfo::MoveInfo( MapObject *pObjToMove):
m_oldLocation = *m_objectToModify->getLocation();
m_newThing = m_objectToModify->getThingTemplate();
m_oldThing = m_objectToModify->getThingTemplate();
m_newName = m_objectToModify->getName();
m_oldName = m_objectToModify->getName();
}

//
Expand Down Expand Up @@ -375,6 +378,9 @@ void MoveInfo::SetZOffset(CWorldBuilderDoc *pDoc, Real z)
void MoveInfo::SetThingTemplate(CWorldBuilderDoc *pDoc, const ThingTemplate* thing)
{
m_newThing = thing;
if (thing && thing != m_oldThing) {
m_newName = thing->getName();
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If thing is null, then m_newName remains unchanged. Is that correct?

DoMove(pDoc);
}

Expand Down Expand Up @@ -403,12 +409,8 @@ void MoveInfo::DoMove(CWorldBuilderDoc *pDoc)
m_objectToModify->setLocation(&m_newLocation);
pDoc->invalObject(m_objectToModify);

if (m_newThing != m_oldThing) {
m_objectToModify->setThingTemplate(m_newThing);
}
if (m_newName != m_oldName) {
m_objectToModify->setName(m_newName);
}
m_objectToModify->setThingTemplate(m_newThing);
m_objectToModify->setName(m_newName);
}

void MoveInfo::UndoMove(CWorldBuilderDoc *pDoc)
Expand All @@ -418,12 +420,8 @@ void MoveInfo::UndoMove(CWorldBuilderDoc *pDoc)
m_objectToModify->setLocation(&m_oldLocation);
pDoc->invalObject(m_objectToModify);

if (m_newThing != m_oldThing) {
m_objectToModify->setThingTemplate(m_oldThing);
}
if (m_newName != m_oldName) {
m_objectToModify->setName(m_oldName);
}
m_objectToModify->setThingTemplate(m_oldThing);
m_objectToModify->setName(m_oldName);
}

/*************************************************************************
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ BOOL EditObjectParameter::OnInitDialog()
void EditObjectParameter::addObject( const ThingTemplate *thingTemplate )
{
HTREEITEM parent = TVI_ROOT;
const char *leafName;
const char *leafName = nullptr;
//
// if we have an thing template in mapObject, we've read it from the new INI database,
// we will sort those items into the tree based on properties of the template that
Expand Down
21 changes: 14 additions & 7 deletions Generals/Code/Tools/WorldBuilder/src/WHeightMapEdit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2012,6 +2012,9 @@ void WorldHeightMapEdit::addObject(MapObject *pMapObj)
void WorldHeightMapEdit::removeFirstObject()
{
MapObject *firstObj = MapObject::TheMapObjectListPtr;
if (!firstObj) {
return;
}
MapObject::TheMapObjectListPtr = firstObj->getNext();
firstObj->setNextMap(nullptr); // so we don't delete the whole list.
deleteInstance(firstObj);
Expand Down Expand Up @@ -2051,20 +2054,22 @@ Bool WorldHeightMapEdit::selectDuplicates()
}

if (pObj->getFlag(FLAG_ROAD_FLAGS)) {
if (pObj->getNext() == nullptr) continue;
if (!pObj->getFlag(FLAG_ROAD_POINT1)) {
continue;
}
if (!prevObj->getFlag(FLAG_ROAD_POINT1)) {
continue;
}
Coord3D nextLoc = *pObj->getNext()->getLocation();
prevObj = prevObj->getNext();
if (!prevObj) continue;
if (!prevObj->getFlag(FLAG_ROAD_POINT2)) {
MapObject *nextObj = pObj->getNext();
if (!nextObj || !nextObj->getFlag(FLAG_ROAD_POINT2)) {
continue;
}
prevLoc = *prevObj->getLocation();
MapObject *prevNextObj = prevObj->getNext();
if (!prevNextObj || !prevNextObj->getFlag(FLAG_ROAD_POINT2)) {
continue;
}
Coord3D nextLoc = *nextObj->getLocation();
prevLoc = *prevNextObj->getLocation();
if (abs(nextLoc.x-prevLoc.x)>DELTA) {
continue; // locations don't match.
}
Expand Down Expand Up @@ -3447,5 +3452,7 @@ void WorldHeightMapEdit::findBoundaryNear(Coord3D *pt, float okDistance, Int *ou
}

(*outNdx) = -1;
(*outHandle) = -1;
if (outHandle) {
(*outHandle) = -1;
}
}
22 changes: 10 additions & 12 deletions GeneralsMD/Code/Tools/WorldBuilder/src/CUndoable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "GameLogic/SidesList.h"
#include "W3DDevice/GameClient/HeightMap.h"
#include "Common/Debug.h"
#include "Common/ThingTemplate.h"
#include "mapobjectprops.h"
#include "ObjectOptions.h"
#include "BuildList.h"
Expand Down Expand Up @@ -346,6 +347,8 @@ MoveInfo::MoveInfo( MapObject *pObjToMove):
m_oldLocation = *m_objectToModify->getLocation();
m_newThing = m_objectToModify->getThingTemplate();
m_oldThing = m_objectToModify->getThingTemplate();
m_newName = m_objectToModify->getName();
m_oldName = m_objectToModify->getName();
}

//
Expand Down Expand Up @@ -375,6 +378,9 @@ void MoveInfo::SetZOffset(CWorldBuilderDoc *pDoc, Real z)
void MoveInfo::SetThingTemplate(CWorldBuilderDoc *pDoc, const ThingTemplate* thing)
{
m_newThing = thing;
if (thing && thing != m_oldThing) {
m_newName = thing->getName();
}
DoMove(pDoc);
}

Expand Down Expand Up @@ -403,12 +409,8 @@ void MoveInfo::DoMove(CWorldBuilderDoc *pDoc)
m_objectToModify->setLocation(&m_newLocation);
pDoc->invalObject(m_objectToModify);

if (m_newThing != m_oldThing) {
m_objectToModify->setThingTemplate(m_newThing);
}
if (m_newName != m_oldName) {
m_objectToModify->setName(m_newName);
}
m_objectToModify->setThingTemplate(m_newThing);
m_objectToModify->setName(m_newName);
}

void MoveInfo::UndoMove(CWorldBuilderDoc *pDoc)
Expand All @@ -418,12 +420,8 @@ void MoveInfo::UndoMove(CWorldBuilderDoc *pDoc)
m_objectToModify->setLocation(&m_oldLocation);
pDoc->invalObject(m_objectToModify);

if (m_newThing != m_oldThing) {
m_objectToModify->setThingTemplate(m_oldThing);
}
if (m_newName != m_oldName) {
m_objectToModify->setName(m_oldName);
}
m_objectToModify->setThingTemplate(m_oldThing);
m_objectToModify->setName(m_oldName);
}

/*************************************************************************
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ BOOL EditObjectParameter::OnInitDialog()
void EditObjectParameter::addObject( const ThingTemplate *thingTemplate )
{
HTREEITEM parent = TVI_ROOT;
const char *leafName;
const char *leafName = nullptr;
//
// if we have an thing template in mapObject, we've read it from the new INI database,
// we will sort those items into the tree based on properties of the template that
Expand Down
21 changes: 14 additions & 7 deletions GeneralsMD/Code/Tools/WorldBuilder/src/WHeightMapEdit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2012,6 +2012,9 @@ void WorldHeightMapEdit::addObject(MapObject *pMapObj)
void WorldHeightMapEdit::removeFirstObject()
{
MapObject *firstObj = MapObject::TheMapObjectListPtr;
if (!firstObj) {
return;
}
MapObject::TheMapObjectListPtr = firstObj->getNext();
firstObj->setNextMap(nullptr); // so we don't delete the whole list.
deleteInstance(firstObj);
Expand Down Expand Up @@ -2051,20 +2054,22 @@ Bool WorldHeightMapEdit::selectDuplicates()
}

if (pObj->getFlag(FLAG_ROAD_FLAGS)) {
if (pObj->getNext() == nullptr) continue;
if (!pObj->getFlag(FLAG_ROAD_POINT1)) {
continue;
}
if (!prevObj->getFlag(FLAG_ROAD_POINT1)) {
continue;
}
Coord3D nextLoc = *pObj->getNext()->getLocation();
prevObj = prevObj->getNext();
if (!prevObj) continue;
if (!prevObj->getFlag(FLAG_ROAD_POINT2)) {
MapObject *nextObj = pObj->getNext();
if (!nextObj || !nextObj->getFlag(FLAG_ROAD_POINT2)) {
continue;
}
prevLoc = *prevObj->getLocation();
MapObject *prevNextObj = prevObj->getNext();
if (!prevNextObj || !prevNextObj->getFlag(FLAG_ROAD_POINT2)) {
continue;
}
Coord3D nextLoc = *nextObj->getLocation();
prevLoc = *prevNextObj->getLocation();
if (abs(nextLoc.x-prevLoc.x)>DELTA) {
continue; // locations don't match.
}
Expand Down Expand Up @@ -3447,5 +3452,7 @@ void WorldHeightMapEdit::findBoundaryNear(Coord3D *pt, float okDistance, Int *ou
}

(*outNdx) = -1;
(*outHandle) = -1;
if (outHandle) {
(*outHandle) = -1;
}
}
Loading