RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

VisList

MarciXs

Sorceror
Uhm I dunno since when it has been added but, PlayerMobile.cs

inside CanSee method there's

public override bool CanSee( Mobile m )
{
if ( m is CharacterStatue )
((CharacterStatue) m).OnRequestedAnimation( this );

if ( m is PlayerMobile && ((PlayerMobile)m).m_VisList.Contains( this ) )
return true;

the fact that you've used m_VisList and not the property makes me wonder, didn't you mean
if ( this.m_VisList.Contains( m ) )

In a sense it would also be more logical. Cause we are testing if we can see a Mobile. Therefore, if the mobile is PlayerMobile, which, say would be true, we would see it if it was in our visibility list.
That makes more sense than, if it is a mobile and if the mobile we are trying to see has us in their visibility list. We only then see them.. Is that how it is supposed to be?

Or I've misunderstood what the VisibilityList is used for? For what I understand it is a list where a mobile can have PlayerMobiles added that they would see. O
 

fwiffo

Sorceror
you have misunderstood the check,

"this" is the mobile who is checking for visibility, m is the mobile who we would like to know if we can see them (we, in fact, are "this").

The visibility list contains mobiles that can see us despite the fact that they could not, so, suppose, m is a gamemaster who added "this" to their vislist, so "this" can see m....I hope you understood :D
 

MarciXs

Sorceror
I thought I stated both version of it, and asked what is it being used for.

The whole point seems strange to me. Take this little example.

public void MakeVisibleToAll(Mobile m)
foreach(Mobile x in World.Mobiles.Values)
if(x is PlayerMobile)
((PlayerMobile)x).VisList.Add(m); // Can I see the mobile? Yes because the mobile would be in my VisList ,

Same when I connect or whatever, just add whoever you want me to see.

This is the code that it is supposed to be, for it to work

public void MakeVisibleToAll(Mobile who)
foreach(Mobile x in World.Mobiles.Values)
if(who is PlayerMobile && x is PlayerMobile)
((PlayerMobile)who).VisList.Add(x); // who has to add every mobile that can see them


Go figure.
 

fwiffo

Sorceror
mmmh, yes, I understand the point, maybe it's done on purpose just to not add things on the core/add overhead, and since it's only used by playermobile, and only by staff members, there could be no other reason.

But even if it's wrong like so, without doing quite a mod in the core, I don't see how you can make it work otherwise.

PS: there is anyway another reason, the list is to be controlled by the player who is adding other mobiles, so you can't keep this list everywhere, but just on yourself...
If you want to add or to remove, it makes a lot of sense this way, it's more secure, and since you can cleanup the list, doing otherwise even so, would be a problem.

To me, the right way, is the reverse check, it makes more sense.
 

MarciXs

Sorceror
I don't understand what you mean about the overhead nor why is it more safe... the list is initialized on every Mobile. if you have 10 players that has to see 1 mobile, you would end up with one iteration in contains call.
If the one player contains 10 players that are being iterated through to check, I don't see the overhead advantage. I mean, if staff use is the only built purpose for this. And you have 500 players online. And every time you check for, whether I can see that Mobile, you iterate through 500 players. (that GM has added to their vislist). If it'd be the other way, every player had one Mobile in their list...

Is there really an advantage? If there is I don't see it.
 

Vorspire

Knight
Why would you check if "m" is a PlayerMobile, then cast "this" to PlayerMobile?
That would make no sense, especially if "this" is always a PlayerMobile.

Iteration over 500 mobiles would take a nano-second anyway so the overhead is minimal, if it was 5 million in the list, then I'd be worried about the implementation.

A collection of Mobiles is just a collection of memory pointers at the end of the day, because the Mobile class is a reference type, so the list's footprint is minimal.

Personally I think it should be done the opposite way, anyone who is in your "Invisble" list should not be seen as opposed to populating a "Visible" list, because the list wouldn't need to contain every Mobile reference.

Also I don't think that it does actually contain a reference to every Mobile that can be seen, I'm pretty sure tat list is used as an override in order to reduce overhead by enforcing the fact that a specific Mobile can be seen before all other checks, enabling the code to return without processing the rest of the un-needed code. The code would be deemed un-needed since any Mobile in your VisList should always be visible against all other odds.
 

MarciXs

Sorceror
Well yeah, actually, if(this._VisList.Contains( m )) check would do...I guess I should have thought the code through before submitting my "own" code.All I did is, I've swapped some variables around.

"The code would be deemed un-needed since any Mobile in your VisList should always be visible against all other odds."

That's what I was wondering about.The way it is, the check to whether I(this) can see Mobile(m) is if I(this) is in Mobile(m) VisList. So basically I can always see someone if I am in their VisList.
The way I see it, I would put whatever I always have to see in my list, and not put myself in whatever I want to see list.

I am aware that it is used to "skip" the other stuff being checked.
 

Vorspire

Knight
I think the implementation is confusing and counter-intuitive, it could be done better in a way that makes more sense when reading it back.

Let's propose a scenario;

Suppose you have a GameMaster who is training a Couselor, call them A and B respectfully for this story;

A wants to show B how o use the [hide command, but A doesn't want to become invisible to B when they demonstrate it, so A adds himself to B's visibility list (how doesn't matter)
So now A is in B's visibility list, which will always allow B to see A, even when hidden.

To summarise, the code is confusing, but it makes more sense when you can think of a working case scenario in which it's useful.

***
I know you're aware of why it's there and what it's intention is, I just like to be thorough in case others who read this thread don't understand :)
 
Top