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!

nullchecking - is this safe?

these are not from my memory - it took them from the //remmed out lines i had in the script to try and find and fix the problem

i have tested this code - and crashed the shard a few times getting it fixed
i actualy had to even take out the 2nd set (the sub line one) - because it then messed up the else if's that followed it (would never get to the right ones for whne the players where above 4th level to steal from)

so do not say i have not tested my code - why don't you try it on your live shard - place it in your stealing script and see if it crashes your shard or not
i know you won't - because it will crash it
 

noobie

Wanderer
Okay, i think you didnt get the point when I said those codes are COMPLETELY IDENTICAL.

Code:
using System;
using System.Collections.Generic;
using System.Collections;
using System.Text;

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            testClass a = new testClass();          
            if (a is testClass) {

                if (((testClass)a).Contains("123"))
                    Console.WriteLine("here");
            }
            
               
        }
    }

    public class testClass : Hashtable
    {
        public testClass() : base() { }
    }

    public class testClass2 : testClass
    {
        public testClass2() : base() { }
    }
}

Code:
using System;
using System.Collections.Generic;
using System.Collections;
using System.Text;

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            testClass a = new testClass();          
            if (a is testClass && ((testClass)a).Contains("123"))
                    Console.WriteLine("here");  
               
        }
    }

    public class testClass : Hashtable
    {
        public testClass() : base() { }
    }

    public class testClass2 : testClass
    {
        public testClass2() : base() { }
    }
}

both of them produce the same IL code if you compile them with optimized option.

main method:
Code:
.method private hidebysig static void Main(string[] args) cil managed
{
      .entrypoint
      .maxstack 2
      .locals init (
            [0] Test.testClass class1)
      L_0000: newobj instance void Test.testClass::.ctor()
      L_0005: stloc.0 
      L_0006: ldloc.0 
      L_0007: brfalse.s L_0020
      L_0009: ldloc.0 
      L_000a: ldstr "123"
      L_000f: callvirt instance bool [mscorlib]System.Collections.Hashtable::Contains(object)
      L_0014: brfalse.s L_0020
      L_0016: ldstr "here"
      L_001b: call void [mscorlib]System.Console::WriteLine(string)
      L_0020: ret 
}
 

daat99

Moderator
Staff member
Lord_Greywolf;630067 said:
these are not from my memory - it took them from the //remmed out lines i had in the script to try and find and fix the problem

i have tested this code - and crashed the shard a few times getting it fixed
i actualy had to even take out the 2nd set (the sub line one) - because it then messed up the else if's that followed it (would never get to the right ones for whne the players where above 4th level to steal from)

so do not say i have not tested my code - why don't you try it on your live shard - place it in your stealing script and see if it crashes your shard or not
i know you won't - because it will crash it

If you're so sure about your code than take 1 of the projects that we posted and modify it to reproduce your crash.

Don't you think it's a bit weired when 4 different persons which aren't c# dummies tells you the exact same thing for over 3 days and they're all wrong?
 

arul

Sorceror
One quick example from distro PlayerMobile.CanSee method

Code:
if( m is PlayerMobile && ((PlayerMobile)m).m_VisList.Contains(this)) ...

So, do you crash every time anyone sees a pack llama? >_<
 
all i know is i added in the line - it crashes the shard
remove line - shard no longer crashes

that is enough testing for me to not to use the line the way it is

and for all i know - it could be the different visual programs i have installed, coporate vs home vs server editions, other programming edititing programs i have, etc that could have changed run time dll files that could be causing the problem also

i just know if i use it - crash - so i do not use it
 

daat99

Moderator
Staff member
Lord_Greywolf;630230 said:
all i know is i added in the line - it crashes the shard
remove line - shard no longer crashes

that is enough testing for me to not to use the line the way it is

and for all i know - it could be the different visual programs i have installed, coporate vs home vs server editions, other programming edititing programs i have, etc that could have changed run time dll files that could be causing the problem also

i just know if i use it - crash - so i do not use it

All we know is:
1. What you're saying goes against the way c# compiler works.
2. We used this kind of code in tons of "RunUO scripts" and other standalone programs not RunUO related with no crash.

I don't really care at this point what you "think" crashed your shard because it's obvious that you have no clue yourself.

Why don't you add the code to your backup server and give us some real crash log with the right code and not something that "you had" in the past?
You don't have to answer that, you won't get it to crash again with those lines of code even if you try...

Fact 1: The code we posted is 100% safe and will not cause a crash (unless it's forces using "throw" on purpose which is not the case here).
Fact 2: You keep claiming that it crash your shard and yet you haven't provided a real code and crash log but only "memorized code" and "recycled crash log".

P.S.
Before you reply to this post I strongly suggest that you refresh your mind browsing the MSDN and reading about boolean evaluations and conditioning.
Try not to "make-up" excuses why the code will crash because your made-up excuses so far were totally misinformed and unrealistic.
The c# compiler compiles the code in the exact same way regardless of what version of visual studio you have installed on your computer.
 
I don't really care at this point what you "think" crashed your shard because it's obvious that you have no clue yourself


I have a clue - a single line - add it in - go to steal from a phack horse - crash - remove line - can steal from a pack horse - so i know which line it is - when you do 1 line at a time - it is easy to figure out

Why don't you add the code to your backup server and give us some real crash log with the right code and not something that "you had" in the past?
You don't have to answer that, you won't get it to crash again with those lines of code even if you try...

must be nice to afford to have back up servers - why don't you send me the money to have one, then i will test it on it

Fact 1: The code we posted is 100% safe and will not cause a crash (unless it's forces using "throw" on purpose which is not the case here).
Fact 2: You keep claiming that it crash your shard and yet you haven't provided a real code and crash log but only "memorized code" and "recycled crash log".

i did provide the real code - it was taken from the remmed out line of the script
i pulled the crash log from the recycle bin, posted it then permently deleted it - again i can not aford drives of super size to keep every file for ever - so i perform disk maintence - so the only thing left of that crash report is what i had posted earlier in the thread for it - so excuse me for not being a big bad rich kid that can afford all kinds of big fancy computer equipement

P.S.
Before you reply to this post I strongly suggest that you refresh your mind browsing the MSDN and reading about boolean evaluations and conditioning.
Try not to "make-up" excuses why the code will crash because your made-up excuses so far were totally misinformed and unrealistic.
The c# compiler compiles the code in the exact same way regardless of what version of visual studio you have installed on your computer.

you better go back to reading them yourself -- there is a reason why there are different versions --- one was how they would compile the code and use it
for example - VB used to run at about 60% the speed of the equivelient VC+ code back when they were in version 1-2 by the time version 6 came out VB then ran at only about 10-15% slower of the equivelient code in VC+
(equivelent code meaning programs that did the exact same thing)
Also optional settings in the compilers will change how the code is read and used - and those vary on the versions, plus numerous addon tools from different versions, and 3rd party ones also - all afffect the way the code compiles
So different versions and runtime dlls do affect code and how it is compiled
Also the different version of the "code makers" will affect it also - like if it is Borland or microsoft or a different compiler - all produce slightly different results

I have been programming/working on computers since the late 70's - and i know how they are sapposed to work - but things can be modified to change that arround - that is the beauty of computers
that is why i 1st wrote that code that way, and why it was one of the last to be removed from the script - because it does not make since that it would crash the shard - but it does - so somewhere, some file, some setting, what ever, has caused it to check that way

ps - the exact code that i coppied in had the //else removed from it and a few tabs to make it more readable - otherwise - it was copy and paste
 

daat99

Moderator
Staff member
Let me just say this.
C# does "short circuit boolean evaluation".
Now please explain to me how the code we posted can crash when it's done with "short circuit boolean evaluation"...

First you'll have to know what that means, after that you'll have to come and say "Yeah, you're right, it's 100% crash free code".

P.S.
I'm really sorry for you that you can't afford 60mb of free space for a backup server... try deleting some movies every now and than...

**edit**
PLEASE read this before you reply
 

arul

Sorceror
LOL, the crashlogs are about few kilobytes in size, you had to have a lot of them to free up some significant amount of space when doing disk maintenance. Do you know what that means?

As for your computer history, do you know the difference between working on a computer and programming? Between digging a hole and building a skyscraper? D'oh.

We know that you're wrong, I really don't understand why you don't want to admit it. Stop telling us fairy tales about compilers, better at first make yourself familiar with their actual name.
 
The compiler is the same, because Visual Studio uses the .net framework compiler, namely csc.exe
It does not matter if you have VS2k5 in whatever edition with SP1 or without. Even if you use SharpDevelop, it will use the same compiler.

There might be different output if you would use the mono compiler - gmcs.exe
But since RunUO does not compile with it...
 

noobie

Wanderer
greywolf, what do you keep telling the same stuff? it is obvious that the code doesnt crash unless you didnt use it correctly in the first place.

and dont make me laugh..VB runs as nearly fast as VC++?
 
Top