Register for your free account! | Forgot your password?

You last visited: Today at 12:06

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Weird code

Discussion on Weird code within the CO2 Private Server forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
miketheking's Avatar
 
elite*gold: 0
Join Date: Oct 2009
Posts: 63
Received Thanks: 10
Weird code

well would some1 tell me why this code gives me an error saying that not all code patterns returns a value while i think all of them do

Code:
public static Game.Location getfreemobcoord(ushort X, ushort Y, ushort Spread)
        {
            Game.Location loc = new Game.Location();
            loc.X = (ushort)Program.Rnd.Next(X, X + Spread);
            loc.Y = (ushort)Program.Rnd.Next(Y, Y + Spread);
            foreach (Game.NPC npc in Game.World.H_NPCs.Values)
            {
                if (npc.Loc.Equals(loc))
                {
                    return getfreemobcoord(X, Y, Spread);
                }
                else
                {
                    foreach (Game.Mob mon in Game.World.H_Mobs.Values)
                    {
                        if (mon.Loc.Equals(loc))
                        {
                            return getfreemobcoord(X, Y, Spread);
                        }
                        else
                        {
                            return loc;
                        }
                    }
                }
            }
        }
miketheking is offline  
Old 06/12/2011, 00:11   #2
 
_DreadNought_'s Avatar
 
elite*gold: 28
Join Date: Jun 2010
Posts: 2,226
Received Thanks: 868
Quote:
Originally Posted by miketheking View Post
well would some1 tell me why this code gives me an error saying that not all code patterns returns a value while i think all of them do

Code:
public static Game.Location getfreemobcoord(ushort X, ushort Y, ushort Spread)
        {
            Game.Location loc = new Game.Location();
            loc.X = (ushort)Program.Rnd.Next(X, X + Spread);
            loc.Y = (ushort)Program.Rnd.Next(Y, Y + Spread);
            foreach (Game.NPC npc in Game.World.H_NPCs.Values)
            {
                if (npc.Loc.Equals(loc))
                {
                    return getfreemobcoord(X, Y, Spread);
                }
                else
                {
                    foreach (Game.Mob mon in Game.World.H_Mobs.Values)
                    {
                        if (mon.Loc.Equals(loc))
                        {
                            return getfreemobcoord(X, Y, Spread);
                        }
                        else
                        {
                            return loc;
                        }
                    }
                }
                [B]return null;//or 0?[/B]
            }
        }
.
_DreadNought_ is offline  
Thanks
1 User
Old 06/12/2011, 03:09   #3
 
elite*gold: 0
Join Date: Jun 2009
Posts: 787
Received Thanks: 314
Wrong, its saying that if that collection World.H_NPC.Values or whatever is empty, the foreach wont execute once and therefore the method will end without returning anything.
_tao4229_ is offline  
Old 06/12/2011, 07:26   #4
 
-Shunsui-'s Avatar
 
elite*gold: 0
Join Date: Apr 2008
Posts: 1,152
Received Thanks: 321
by the way this that you are doing is poor, i recommend using Kinshi's TinyMap server for your source, it helps as well with this you are doing
-Shunsui- is offline  
Old 06/12/2011, 13:15   #5
 
_DreadNought_'s Avatar
 
elite*gold: 28
Join Date: Jun 2010
Posts: 2,226
Received Thanks: 868
Quote:
Originally Posted by _tao4229_ View Post
Wrong, its saying that if that collection World.H_NPC.Values or whatever is empty, the foreach wont execute once and therefore the method will end without returning anything.
So yea my code would fix that. You are correct tho.

Should note my code I put in is mis-placed, move it to somewhere after the foreach loop.
_DreadNought_ is offline  
Old 06/12/2011, 15:26   #6
 
elite*gold: 0
Join Date: May 2011
Posts: 1,769
Received Thanks: 756
Quote:
Originally Posted by _DreadNought_ View Post
.
Why would you return it at first? Then it would loop one time and return. It should be outside the foreach loop.
BaussHacker is offline  
Old 06/12/2011, 16:08   #7
 
_DreadNought_'s Avatar
 
elite*gold: 28
Join Date: Jun 2010
Posts: 2,226
Received Thanks: 868
Was a mistake since I did it in this tiny quick reply thingy. Look at the post above yours
_DreadNought_ is offline  
Reply


Similar Threads Similar Threads
Weird one.
10/21/2010 - Dekaron Private Server - 2 Replies
If you have a solution to this ill give u a cookie Normal characters can play fine and everything works, however a GM or DEV char either DCs on map load or crashes when trying to use commands. SN.txt is applied and iv tried various fixes but nothing works so far. Any suggestions?
Weird...
01/11/2010 - Dekaron - 46 Replies
I logged on this morning, using the old xigncode and everything, cuz I didn't know that it had been updated. Anyway, I figured it out pretty quick, so I tried to log in and play legit...which didn't work. Ever since then, I cannot even get 2m to load. I tried reinstalling and playing totally legit, without any hacks in the folder at all, as if I was seriously a legit player, and I'm still having the same problem. Any ideas why?
This is weird
04/22/2009 - SRO Private Server - 3 Replies
:confused: wow i finally Download everything and when i get on game the only server that's up is Vip ecsro why aren't fembria and ecsro up?



All times are GMT +1. The time now is 12:06.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.