FIX: Crash when server is disaibling

This commit is contained in:
2026-07-10 21:45:52 +02:00
parent d3d9b1a238
commit 26e5376030
4 changed files with 45 additions and 44 deletions

View File

@@ -258,9 +258,10 @@ void Minecraft::selectLevel( const std::string& levelId, const std::string& leve
void Minecraft::setLevel(Level* level, const std::string& message /* ="" */, LocalPlayer* forceInsertPlayer /* = NULL */) {
cameraTargetPlayer = NULL;
LOGI("Seed is %ld\n", level->getSeed());
if (level != NULL) {
LOGI("Seed is %ld\n", level->getSeed());
level->raknetInstance = raknetInstance;
gameMode->initLevel(level);

View File

@@ -1077,13 +1077,13 @@ void LevelRenderer::playSound(const std::string& name, float x, float y, float z
float dd = 16;
if (volume > 1) dd *= volume;
if (mc->cameraTargetPlayer->distanceToSqr(x, y, z) < dd * dd) {
if (mc->cameraTargetPlayer != NULL && mc->cameraTargetPlayer->distanceToSqr(x, y, z) < dd * dd) {
mc->soundEngine->play(name, x, y, z, volume, pitch);
}
}
void LevelRenderer::addParticle(const std::string& name, float x, float y, float z, float xa, float ya, float za, int data) {
if (mc->cameraTargetPlayer != NULL) {
float xd = mc->cameraTargetPlayer->x - x;
float yd = mc->cameraTargetPlayer->y - y;
float zd = mc->cameraTargetPlayer->z - z;
@@ -1125,6 +1125,7 @@ void LevelRenderer::addParticle(const std::string& name, float x, float y, float
//sw.stop();
//sw.printEvery(50, "add-particle-string");
}
}
/*
void LevelRenderer::addParticle(ParticleType::Id name, float x, float y, float z, float xa, float ya, float za, int data) {

View File

@@ -124,6 +124,8 @@ void ClientSideNetworkHandler::onDisconnect(const RakNet::RakNetGUID& guid)
minecraft->setLevel(NULL);
#ifndef STANDALONE_SERVER
minecraft->gui.addMessage("Disconnected from server");
// TODO: screen with error
minecraft->screenChooser.setScreen(SCREEN_STARTMENU);
#endif
}

View File

@@ -697,12 +697,9 @@ void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& source, WantCrea
}
}
// for (int i = 0; i < items.size(); i++) {
// RemoveItemPacket removePacket(packet->playerId, items.at(i).count, items.at(i).getAuxValue(), items.at(i).id);
// raknetInstance->send(source, removePacket);
// p->inventory->removeResource(ItemInstance(items.at(i).id, items.at(i).count, items.at(i).getAuxValue()));
// }
for (int i = 0; i < items.size(); i++) {
p->inventory->removeResource(ItemInstance(items.at(i).id, items.at(i).count, items.at(i).getAuxValue()));
}
// TakeItemPacket itemAdd(p->entityId, wantCreate.count, wantCreate.getAuxValue(), wantCreate.id);
// raknetInstance->send(source, itemAdd);