coleseya
08-04-2011, 19:16
Salve,
avrei un problema di questo genere, come errore generico:
Error during removing user from room:System.IndexOutOfRangeException: Index was outside the bounds of the array.
at Rooms.Room.RemoveUserFromRoom(GameClient Session, Boolean NotifyClient, Boolean NotifyKick)
qui è il codcie dorgente dove è posizionato l'errore sapete dirmi dove e come sbaglio?
public void RemoveUserFromRoom(GameClient Session, Boolean NotifyClient, Boolean NotifyKick)
{
try
{
if (Session == null)
{
return;
}
if (Session.GetRooms() == null)
return;
RoomUser User = GetRoomUserByRooms(Session.GetRooms().Id);
if (User != null)
{
int ID = User.InternalRoomID;
UserList[User.InternalRoomID] = null;
User.InternalRoomID = -1;
mGameMap[User.X, User.Y] = 0;
}
if (NotifyClient)
{
if (NotifyKick)
{
Session.GetMessageHandler().GetResponse().Init(33);
Session.GetMessageHandler().GetResponse().AppendInt32(4008);
Session.GetMessageHandler().SendResponse();
}
Session.GetMessageHandler().GetResponse().Init(18);
Session.GetMessageHandler().SendResponse();
}
List<RoomUser> PetsToRemove = new List<RoomUser>();
if (User != null)
{
if (Session.GetRooms() != null)
{
if (!User.IsSpectator)
{
//UserMatrix[User.X, User.Y] = false;
ServerMessage LeaveMessage = new ServerMessage(29);
LeaveMessage.AppendRawInt32(User.VirtualId);
SendMessage(LeaveMessage);
if (Session.GetRooms() != null)
{
if (HasActiveTrade(Session.GetRooms().Id))
{
TryStopTrade(Session.GetRooms().Id);
}
if (Session.GetRooms().Username.ToLower() == Owner.ToLower())
{
if (HasOngoingEvent)
{
Event = null;
ServerMessage Message = new ServerMessage(370);
Message.AppendStringWithBreak("-1");
SendMessage(Message);
}
}
Session.GetRooms().OnLeaveRoom();
}
UpdateUserCount();
List<RoomUser> Bots = new List<RoomUser>();
for (int i = 0; i < UserList.Length; i++)
{
RoomUser Usr = UserList[i];
if (Usr == null)
continue;
if (Usr.IsBot)
Bots.Add(Usr);
}
foreach (RoomUser Bot in Bots)
{
Bot.BotAI.OnUserLeaveRoom(Session);
if (Bot.IsPet && Bot.PetData.OwnerId == Session.GetRooms().Id && !CheckRights(Session, true))
{
PetsToRemove.Add(Bot);
}
}
}
}
}
foreach (RoomUser toRemove in PetsToRemove)
{
Session.GetRooms().GetInventoryComponent().AddPet(toRemove.PetData);
RemoveBot(toRemove.VirtualId, false);
}
}
catch (Exception e) { Logging.LogCriticalException("Error during removing user from room:" + e.ToString()); }
}
Attento suggerimenti, Grazie!
avrei un problema di questo genere, come errore generico:
Error during removing user from room:System.IndexOutOfRangeException: Index was outside the bounds of the array.
at Rooms.Room.RemoveUserFromRoom(GameClient Session, Boolean NotifyClient, Boolean NotifyKick)
qui è il codcie dorgente dove è posizionato l'errore sapete dirmi dove e come sbaglio?
public void RemoveUserFromRoom(GameClient Session, Boolean NotifyClient, Boolean NotifyKick)
{
try
{
if (Session == null)
{
return;
}
if (Session.GetRooms() == null)
return;
RoomUser User = GetRoomUserByRooms(Session.GetRooms().Id);
if (User != null)
{
int ID = User.InternalRoomID;
UserList[User.InternalRoomID] = null;
User.InternalRoomID = -1;
mGameMap[User.X, User.Y] = 0;
}
if (NotifyClient)
{
if (NotifyKick)
{
Session.GetMessageHandler().GetResponse().Init(33);
Session.GetMessageHandler().GetResponse().AppendInt32(4008);
Session.GetMessageHandler().SendResponse();
}
Session.GetMessageHandler().GetResponse().Init(18);
Session.GetMessageHandler().SendResponse();
}
List<RoomUser> PetsToRemove = new List<RoomUser>();
if (User != null)
{
if (Session.GetRooms() != null)
{
if (!User.IsSpectator)
{
//UserMatrix[User.X, User.Y] = false;
ServerMessage LeaveMessage = new ServerMessage(29);
LeaveMessage.AppendRawInt32(User.VirtualId);
SendMessage(LeaveMessage);
if (Session.GetRooms() != null)
{
if (HasActiveTrade(Session.GetRooms().Id))
{
TryStopTrade(Session.GetRooms().Id);
}
if (Session.GetRooms().Username.ToLower() == Owner.ToLower())
{
if (HasOngoingEvent)
{
Event = null;
ServerMessage Message = new ServerMessage(370);
Message.AppendStringWithBreak("-1");
SendMessage(Message);
}
}
Session.GetRooms().OnLeaveRoom();
}
UpdateUserCount();
List<RoomUser> Bots = new List<RoomUser>();
for (int i = 0; i < UserList.Length; i++)
{
RoomUser Usr = UserList[i];
if (Usr == null)
continue;
if (Usr.IsBot)
Bots.Add(Usr);
}
foreach (RoomUser Bot in Bots)
{
Bot.BotAI.OnUserLeaveRoom(Session);
if (Bot.IsPet && Bot.PetData.OwnerId == Session.GetRooms().Id && !CheckRights(Session, true))
{
PetsToRemove.Add(Bot);
}
}
}
}
}
foreach (RoomUser toRemove in PetsToRemove)
{
Session.GetRooms().GetInventoryComponent().AddPet(toRemove.PetData);
RemoveBot(toRemove.VirtualId, false);
}
}
catch (Exception e) { Logging.LogCriticalException("Error during removing user from room:" + e.ToString()); }
}
Attento suggerimenti, Grazie!