Fix not being able to place water/lava/bedrock after loading new map in singleplayer (Thanks Guri)

This commit is contained in:
UnknownShadow200 2020-09-20 15:44:34 +10:00
parent 31ea08eead
commit 4875746bf6

View File

@ -118,15 +118,8 @@ int Ping_AveragePingMS(void) {
/*########################################################################################################################* /*########################################################################################################################*
*-------------------------------------------------Singleplayer connection-------------------------------------------------* *-------------------------------------------------Singleplayer connection-------------------------------------------------*
*#########################################################################################################################*/ *#########################################################################################################################*/
#define SP_HasDir(path) (String_IndexOf(&path, '/') >= 0 || String_IndexOf(&path, '\\') >= 0) static void SPConnection_ResetBlockPerms(void) {
static void SPConnection_BeginConnect(void) {
static const String logName = String_FromConst("Singleplayer");
String path;
RNGState rnd;
int i, count; int i, count;
Chat_SetLogName(&logName);
Game_UseCPEBlocks = Game_UseCPE;
count = Game_UseCPEBlocks ? BLOCK_CPE_COUNT : BLOCK_ORIGINAL_COUNT; count = Game_UseCPEBlocks ? BLOCK_CPE_COUNT : BLOCK_ORIGINAL_COUNT;
for (i = 1; i < count; i++) { for (i = 1; i < count; i++) {
@ -134,12 +127,21 @@ static void SPConnection_BeginConnect(void) {
Blocks.CanDelete[i] = true; Blocks.CanDelete[i] = true;
} }
Event_RaiseVoid(&BlockEvents.PermissionsChanged); Event_RaiseVoid(&BlockEvents.PermissionsChanged);
}
#define SP_HasDir(path) (String_IndexOf(&path, '/') >= 0 || String_IndexOf(&path, '\\') >= 0)
static void SPConnection_BeginConnect(void) {
static const String logName = String_FromConst("Singleplayer");
String path;
RNGState rnd;
Chat_SetLogName(&logName);
Game_UseCPEBlocks = Game_UseCPE;
SPConnection_ResetBlockPerms();
/* For when user drops a map file onto ClassiCube.exe */ /* For when user drops a map file onto ClassiCube.exe */
path = Game_Username; path = Game_Username;
if (SP_HasDir(path) && File_Exists(&path)) { if (SP_HasDir(path) && File_Exists(&path)) {
Map_LoadFrom(&path); Map_LoadFrom(&path); return;
return;
} }
Random_SeedFromCurrentTime(&rnd); Random_SeedFromCurrentTime(&rnd);
@ -491,10 +493,12 @@ static void OnNewMap(void) {
} }
static void OnReset(void) { static void OnReset(void) {
if (Server.IsSinglePlayer) return; if (Server.IsSinglePlayer) {
SPConnection_ResetBlockPerms();
} else {
net_writeFailed = false; net_writeFailed = false;
OnFree(); OnFree();
}
} }
static void OnInit(void) { static void OnInit(void) {