mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-15 10:35:11 -04:00
Fix launcher crash when completely missing resume info, port respawn changes by goodly to C client
This commit is contained in:
parent
f889ae6223
commit
d2fa018b17
@ -179,21 +179,20 @@ namespace ClassicalSharp.Entities {
|
||||
Vector3I P = Vector3I.Floor(spawn);
|
||||
AABB bb;
|
||||
|
||||
// Spawn player at highest valid position
|
||||
if (Hacks.CanNoclip) {
|
||||
if (game.World.IsValidPos(P)) {
|
||||
bb = AABB.Make(spawn, Size);
|
||||
for (int y = P.Y; y <= game.World.Height; y++) {
|
||||
float spawnY = Respawn.HighestFreeY(game, ref bb);
|
||||
if (spawnY == float.NegativeInfinity) {
|
||||
BlockID block = game.World.GetPhysicsBlock(P.X, y, P.Z);
|
||||
float height = BlockInfo.Collide[block] == CollideType.Solid ? BlockInfo.MaxBB[block].Y : 0;
|
||||
spawn.Y = y + height + Entity.Adjustment;
|
||||
break;
|
||||
}
|
||||
bb.Min.Y += 1; bb.Max.Y += 1;
|
||||
}
|
||||
}
|
||||
// Spawn player at highest solid position to match vanilla Minecraft classic
|
||||
// Only when player can noclip, since this can let you 'clip' to above solid blocks
|
||||
if (Hacks.CanNoclip && game.World.IsValidPos(P)) {
|
||||
bb = AABB.Make(spawn, Size);
|
||||
for (int y = P.Y; y <= game.World.Height; y++) {
|
||||
float spawnY = Respawn.HighestFreeY(game, ref bb);
|
||||
if (spawnY == float.NegativeInfinity) {
|
||||
BlockID block = game.World.GetPhysicsBlock(P.X, y, P.Z);
|
||||
float height = BlockInfo.Collide[block] == CollideType.Solid ? BlockInfo.MaxBB[block].Y : 0;
|
||||
spawn.Y = y + height + Entity.Adjustment;
|
||||
break;
|
||||
}
|
||||
bb.Min.Y += 1; bb.Max.Y += 1;
|
||||
}
|
||||
}
|
||||
|
||||
spawn.Y += 2/16f;
|
||||
@ -224,15 +223,16 @@ namespace ClassicalSharp.Entities {
|
||||
game.Chat.Add("&cCannot set spawn midair when noclip is disabled");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Spawn is normally centered to match vanilla Minecraft classic
|
||||
if (!Hacks.CanNoclip) {
|
||||
Spawn.X = Position.X;
|
||||
Spawn.Y = Position.Y;
|
||||
Spawn.Z = Position.Z;
|
||||
Spawn = Position;
|
||||
} else {
|
||||
Spawn.X = Utils.Floor(Position.X) + 0.5f;
|
||||
Spawn.Y = Position.Y;
|
||||
Spawn.Z = Utils.Floor(Position.Z) + 0.5f;
|
||||
}
|
||||
|
||||
SpawnRotY = RotY;
|
||||
SpawnHeadX = HeadX;
|
||||
}
|
||||
|
27
src/Entity.c
27
src/Entity.c
@ -958,8 +958,9 @@ static void LocalPlayer_DoRespawn(void) {
|
||||
if (!World_Blocks) return;
|
||||
Vector3I_Floor(&pos, &spawn);
|
||||
|
||||
/* Spawn player at highest valid position */
|
||||
if (World_IsValidPos_3I(pos)) {
|
||||
/* Spawn player at highest solid position to match vanilla Minecraft classic */
|
||||
/* Only when player can noclip, since this can let you 'clip' to above solid blocks */
|
||||
if (p->Hacks.CanNoclip && World_IsValidPos_3I(pos)) {
|
||||
AABB_Make(&bb, &spawn, &p->Base.Size);
|
||||
for (y = pos.Y; y <= World_Height; y++) {
|
||||
spawnY = Respawn_HighestSolidY(&bb);
|
||||
@ -1000,11 +1001,23 @@ static bool LocalPlayer_HandleRespawn(void) {
|
||||
static bool LocalPlayer_HandleSetSpawn(void) {
|
||||
struct LocalPlayer* p = &LocalPlayer_Instance;
|
||||
if (p->Hacks.CanRespawn) {
|
||||
p->Spawn.X = Math_Floor(p->Base.Position.X) + 0.5f;
|
||||
p->Spawn.Y = p->Base.Position.Y;
|
||||
p->Spawn.Z = Math_Floor(p->Base.Position.Z) + 0.5f;
|
||||
p->SpawnRotY = p->Base.RotY;
|
||||
p->SpawnHeadX = p->Base.HeadX;
|
||||
|
||||
if (!p->Hacks.CanNoclip && !p->Base.OnGround) {
|
||||
Chat_AddRaw("&cCannot set spawn midair when noclip is disabled");
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Spawn is normally centered to match vanilla Minecraft classic */
|
||||
if (!p->Hacks.CanNoclip) {
|
||||
p->Spawn = p->Base.Position;
|
||||
} else {
|
||||
p->Spawn.X = Math_Floor(p->Base.Position.X) + 0.5f;
|
||||
p->Spawn.Y = p->Base.Position.Y;
|
||||
p->Spawn.Z = Math_Floor(p->Base.Position.Z) + 0.5f;
|
||||
}
|
||||
|
||||
p->SpawnRotY = p->Base.RotY;
|
||||
p->SpawnHeadX = p->Base.HeadX;
|
||||
}
|
||||
return LocalPlayer_HandleRespawn();
|
||||
}
|
||||
|
@ -665,14 +665,14 @@ struct ResumeInfo {
|
||||
|
||||
CC_NOINLINE static void MainScreen_GetResume(struct ResumeInfo* info, bool full) {
|
||||
String_InitArray(info->Server, info->_serverBuffer);
|
||||
Options_Get("launcher-server", &info->Server, NULL);
|
||||
Options_Get("launcher-server", &info->Server, "");
|
||||
String_InitArray(info->User, info->_userBuffer);
|
||||
Options_Get("launcher-username", &info->User, NULL);
|
||||
Options_Get("launcher-username", &info->User, "");
|
||||
|
||||
String_InitArray(info->Ip, info->_ipBuffer);
|
||||
Options_Get("launcher-ip", &info->Ip, NULL);
|
||||
Options_Get("launcher-ip", &info->Ip, "");
|
||||
String_InitArray(info->Port, info->_portBuffer);
|
||||
Options_Get("launcher-port", &info->Port, NULL);
|
||||
Options_Get("launcher-port", &info->Port, "");
|
||||
|
||||
if (!full) return;
|
||||
String_InitArray(info->Mppass, info->_mppassBuffer);
|
||||
@ -683,7 +683,7 @@ CC_NOINLINE static void MainScreen_GetResume(struct ResumeInfo* info, bool full)
|
||||
info->Ip.length && info->Port.length;
|
||||
}
|
||||
|
||||
CC_NOINLINE void MainScreen_Error(struct LWebTask* task, const char* action) {
|
||||
CC_NOINLINE static void MainScreen_Error(struct LWebTask* task, const char* action) {
|
||||
String str; char strBuffer[STRING_SIZE];
|
||||
struct MainScreen* s = &MainScreen_Instance;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user