Quote:
Originally Posted by Mentalis
Edit:
Since we have this
Code:
void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
try
{
MyClient.EndSend();
}
catch { }
try
{
if (!Program.EndSession)
if (MyClient != null)
Step();
}
catch { }
try
{
if (Loaded)
if (DateTime.Now > LastSave.AddSeconds(8))
{
LastSave = DateTime.Now;
Database.SaveCharacter(this, MyClient.AuthInfo.Account);
}
}
catch { }
}
|
I didn't look into that source yet, but i have one comment to point out, in your first example
Code:
void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
try
{
MyClient.EndSend();
}
catch { }
try
{
if (!Program.EndSession)
if (MyClient != null)
Step();
}
catch { }
try
{
if (Loaded)
if (DateTime.Now > LastSave.AddSeconds(8))
{
LastSave = DateTime.Now;
Database.SaveCharacter(this, MyClient.AuthInfo.Account);
}
}
catch { }
}
you are using many useless try catch blocks, this takes more time to process, just one on the whole block of sentences would do the same, and you might want to do some notification :}
Code:
void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
try
{
MyClient.EndSend();
if (!Program.EndSession)
if (MyClient != null)
Step();
if (Loaded)
if (DateTime.Now > LastSave.AddSeconds(8))
{
LastSave = DateTime.Now;
Database.SaveCharacter(this, MyClient.AuthInfo.Account);
}
}
catch(Exception ex) { Console.WriteLine(ex.Message); }
}
And about stopping people from login if the character is already online, check if the character id exists in the client pool, if it does, disconnect the socket of the client that is requesting to login
Update: just looked at the code you suggested, i don't think adding anything to that case will work, since the client is already logged on this case just informs your friends and enemies that you are online..