mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-17 19:45:23 -04:00
Fix crash when failing to connect to server
This commit is contained in:
parent
8d76c0c1b1
commit
7db39d73ee
@ -59,7 +59,7 @@ namespace ClassicalSharp.Network {
|
||||
cpe = new CPEProtocol(game);
|
||||
cpeBlockDefs = new CPEProtocolBlockDefs(game);
|
||||
wom = new WoMProtocol(game);
|
||||
ResetProtocols();
|
||||
ResetState();
|
||||
|
||||
classic.WriteLogin(game.Username, game.Mppass);
|
||||
SendPacket();
|
||||
@ -190,21 +190,22 @@ namespace ClassicalSharp.Network {
|
||||
packetSizes[i] = 0;
|
||||
}
|
||||
|
||||
reader.ExtendedPositions = false; reader.ExtendedBlocks = false;
|
||||
writer.ExtendedPositions = false; writer.ExtendedBlocks = false;
|
||||
BlockInfo.SetMaxUsed(255);
|
||||
|
||||
ResetProtocols();
|
||||
cpeData.Reset();
|
||||
ResetState();
|
||||
Dispose();
|
||||
}
|
||||
|
||||
void ResetProtocols() {
|
||||
void ResetState() {
|
||||
if (classic == null) return; // null if no successful connection ever made before
|
||||
|
||||
cpeData.Reset();
|
||||
classic.Reset();
|
||||
cpe.Reset();
|
||||
cpeBlockDefs.Reset();
|
||||
wom.Reset();
|
||||
|
||||
reader.ExtendedPositions = false; reader.ExtendedBlocks = false;
|
||||
writer.ExtendedPositions = false; writer.ExtendedBlocks = false;
|
||||
}
|
||||
|
||||
internal Action[] handlers = new Action[256];
|
||||
@ -225,6 +226,7 @@ namespace ClassicalSharp.Network {
|
||||
|
||||
public override void OnNewMap(Game game) {
|
||||
// wipe all existing entity states
|
||||
if (classic == null) return;
|
||||
for (int i = 0; i < EntityList.MaxCount; i++) {
|
||||
classic.RemoveEntity((byte)i);
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ String_AppendConst(&logMsg, "\r\n");
|
||||
String_AppendConst(&logMsg, "Please report the crash to github.com/UnknownShadow200/ClassicalSharp/issues so we can fix it.");
|
||||
|
||||
LONG WINAPI ErrorHandler_UnhandledFilter(struct _EXCEPTION_POINTERS* pInfo) {
|
||||
//pInfo->ExceptionRecord->
|
||||
pInfo->ExceptionRecord->
|
||||
return EXCEPTION_EXECUTE_HANDLER;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user