File tree 2 files changed +15
-3
lines changed
2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -434,7 +434,7 @@ void GenerateNotifier::getEvents(
434
434
ObjDefManager::ObjDefManager (IGameDef *gamedef, ObjDefType type)
435
435
{
436
436
m_objtype = type;
437
- m_ndef = gamedef->getNodeDefManager ();
437
+ m_ndef = gamedef ? gamedef ->getNodeDefManager () : NULL ;
438
438
}
439
439
440
440
@@ -471,7 +471,16 @@ ObjDef *ObjDefManager::get(ObjDefHandle handle) const
471
471
ObjDef *ObjDefManager::set (ObjDefHandle handle, ObjDef *obj)
472
472
{
473
473
u32 index = validateHandle (handle);
474
- return (index != OBJDEF_INVALID_INDEX) ? setRaw (index , obj) : NULL ;
474
+ if (index == OBJDEF_INVALID_INDEX)
475
+ return NULL ;
476
+
477
+ ObjDef *oldobj = setRaw (index , obj);
478
+
479
+ obj->uid = oldobj->uid ;
480
+ obj->index = oldobj->index ;
481
+ obj->handle = oldobj->handle ;
482
+
483
+ return oldobj;
475
484
}
476
485
477
486
Original file line number Diff line number Diff line change @@ -206,12 +206,15 @@ class ObjDef {
206
206
std::string name;
207
207
};
208
208
209
+ // WARNING: Ownership of ObjDefs is transferred to the ObjDefManager it is
210
+ // added/set to. Note that ObjDefs managed by ObjDefManager are NOT refcounted,
211
+ // so the same ObjDef instance must not be referenced multiple
209
212
class ObjDefManager {
210
213
public:
211
214
ObjDefManager (IGameDef *gamedef, ObjDefType type);
212
215
virtual ~ObjDefManager ();
213
216
214
- virtual const char *getObjectTitle () const = 0;
217
+ virtual const char *getObjectTitle () const { return " ObjDef " ; }
215
218
216
219
virtual void clear ();
217
220
virtual ObjDef *getByName (const std::string &name) const ;
You can’t perform that action at this time.
0 commit comments