|
You last visited: Today at 12:06
Advertisement
Weird code
Discussion on Weird code within the CO2 Private Server forum part of the Conquer Online 2 category.
06/11/2011, 23:49
|
#1
|
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;
}
}
}
}
}
|
|
|
06/12/2011, 00:11
|
#2
|
elite*gold: 28
Join Date: Jun 2010
Posts: 2,226
Received Thanks: 868
|
Quote:
Originally Posted by miketheking
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]
}
}
|
.
|
|
|
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.
|
|
|
06/12/2011, 07:26
|
#4
|
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
|
|
|
06/12/2011, 13:15
|
#5
|
elite*gold: 28
Join Date: Jun 2010
Posts: 2,226
Received Thanks: 868
|
Quote:
Originally Posted by _tao4229_
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.
|
|
|
06/12/2011, 15:26
|
#6
|
elite*gold: 0
Join Date: May 2011
Posts: 1,769
Received Thanks: 756
|
Quote:
Originally Posted by _DreadNought_
.
|
Why would you return it at first? Then it would loop one time and return. It should be outside the foreach loop.
|
|
|
06/12/2011, 16:08
|
#7
|
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
|
|
|
 |
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.
|
|