void ScValue::setNative(BaseScriptable *val, bool persistent) { if (_type == VAL_VARIABLE_REF) { _valRef->setNative(val, persistent); return; } if (val == nullptr) { setNULL(); } else { if (_valNative && !_persistent) { _valNative->_refCount--; if (_valNative->_refCount <= 0) { if (_valNative != val) { delete _valNative; } _valNative = nullptr; } } _type = VAL_NATIVE; _persistent = persistent; _valNative = val; if (_valNative && !_persistent) { _valNative->_refCount++; } } }
TileMap(int w, int h, int tile_w, int tile_h, TileSet* ts) : size(w,h), tile_size(tile_w, tile_h), start_pos(0,0), tiles(ts) { assert(w>0 and h>0); assert(tile_w>0 and tile_h>0); assert(tiles); data = new Tile* [size.x * size.y]; setNULL(data, size.x * size.y); };