Internalise void Remove() so that it entirely kills any pointer object.
Printable View
Internalise void Remove() so that it entirely kills any pointer object.
Remove() does not fully invalidate pointers for datatypes ffc, item, lweapon, eweapon, and uses a substandard way to remove npc pointers. Have a look at what void Remove() does, and you'll understand.
An internal Remove() would fully remove the pointer.
Remove is actually a bit of a hack. It doesn't really remove the object, it just makes it so that the next frame ZC will see that it should be removed (deleted). Internalizing it is actually a good suggestion, though actually deleting it might be bad. (Like my pappy used to say: Don't change horses midstream.) :smoke:
I get that. I know its a hack. I just don't see the useful difference to ZoriaRPG if it is internalized or not.
So you want it to remove objects faster? Or are you saying you want if(pointer) to evaluate to false if it is invalid?
Right, isValid() should evaluate false when a pointer is specifically removed.Iit would avoid the hack-ish methods that I'm using to determine if it should be skipped. Again, for loops (especially with a Waitframe(), as those can become cumulative) would be optimised if pointers are removed. It would allow the loop to advance in the same frame, and wouldn't require workarounds for multiple loops that run per frame.
If you're curious, here is a set of utility functions that I use with the present Remove() function:
I use those, in place of isValid(), which works for the present, but it would still be better to remove the pointers. They otherwise just use stack/ heap space anyway.Code:///Used to check if any given pointer is on screen. Move pointers to X = 32768 to effectively kill them with void Remove().
bool isOnScreen(item i){
if( i->isValid() && i->X != 32768 ) {
return true;
}
return false;
}
bool isOnScreen(ffc f){
if( f->Data > 0 && f->X != 32768 ) {
return true;
}
return false;
}
bool isOnScreen(npc n){
if( n->isValid() && n->X != 32768 ) {
return true;
}
return false;
}
bool isOnScreen(eweapon e){
if( e->isValid() && e->X != 32768 ) {
return true;
}
return false;
}
bool isOnScreen(lweapon l){
if( l->isValid() && l->X != 32768 ) {
return true;
}
return false;
}
Again, it's a request for the future. It would be cleaner to remove the pointers, rather than moving them off-screen.
I can see how deleting the ZScript void Remove might be bad, if anything depends on it.
You could do void Rem() for the internal side, to prevent compatibility conflicts.
So basically what you are saying is you want to remove objects without waiting a frame. You could have just said that.
I could have, and then answered other questions from someone else, about why I don't want to wait a frame...
It's low priority, and for the record, I'll make suggestions for improvements, even if they don't directly pertain to my own goals. In this case, I have utility functions that mimic the behaviour that I need, but I've run into instances in other projects where this became an issue. That notwithstanding, I would likely have made this suggestion in time, simply because if a user can create a pointer, they should be able to directly remove it. It's tidier that way.
When was I required to have reasons, anyway? :D