mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-13 09:35:23 -04:00
Simplify block permissions reset code
This commit is contained in:
parent
18dcbd710f
commit
168143fecc
@ -684,16 +684,9 @@ static void OnReset(void) {
|
|||||||
Block_RecalculateAllSpriteBB();
|
Block_RecalculateAllSpriteBB();
|
||||||
|
|
||||||
for (block = BLOCK_AIR; block < BLOCK_COUNT; block++) {
|
for (block = BLOCK_AIR; block < BLOCK_COUNT; block++) {
|
||||||
Blocks.CanPlace[block] = true;
|
Blocks.CanPlace[block] = true;
|
||||||
Blocks.CanDelete[block] = true;
|
Blocks.CanDelete[block] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Blocks.CanPlace[BLOCK_AIR] = false; Blocks.CanDelete[BLOCK_AIR] = false;
|
|
||||||
Blocks.CanPlace[BLOCK_LAVA] = false; Blocks.CanDelete[BLOCK_LAVA] = false;
|
|
||||||
Blocks.CanPlace[BLOCK_WATER] = false; Blocks.CanDelete[BLOCK_WATER] = false;
|
|
||||||
Blocks.CanPlace[BLOCK_STILL_LAVA] = false; Blocks.CanDelete[BLOCK_STILL_LAVA] = false;
|
|
||||||
Blocks.CanPlace[BLOCK_STILL_WATER] = false; Blocks.CanDelete[BLOCK_STILL_WATER] = false;
|
|
||||||
Blocks.CanPlace[BLOCK_BEDROCK] = false; Blocks.CanDelete[BLOCK_BEDROCK] = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void OnAtlasChanged(void* obj) { Block_RecalculateAllSpriteBB(); }
|
static void OnAtlasChanged(void* obj) { Block_RecalculateAllSpriteBB(); }
|
||||||
|
29
src/Server.c
29
src/Server.c
@ -118,17 +118,6 @@ int Ping_AveragePingMS(void) {
|
|||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*-------------------------------------------------Singleplayer connection-------------------------------------------------*
|
*-------------------------------------------------Singleplayer connection-------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
static void SPConnection_ResetBlockPerms(void) {
|
|
||||||
int i, count;
|
|
||||||
count = Game_UseCPEBlocks ? BLOCK_CPE_COUNT : BLOCK_ORIGINAL_COUNT;
|
|
||||||
|
|
||||||
for (i = 1; i < count; i++) {
|
|
||||||
Blocks.CanPlace[i] = true;
|
|
||||||
Blocks.CanDelete[i] = true;
|
|
||||||
}
|
|
||||||
Event_RaiseVoid(&BlockEvents.PermissionsChanged);
|
|
||||||
}
|
|
||||||
|
|
||||||
#define SP_HasDir(path) (String_IndexOf(&path, '/') >= 0 || String_IndexOf(&path, '\\') >= 0)
|
#define SP_HasDir(path) (String_IndexOf(&path, '/') >= 0 || String_IndexOf(&path, '\\') >= 0)
|
||||||
static void SPConnection_BeginConnect(void) {
|
static void SPConnection_BeginConnect(void) {
|
||||||
static const String logName = String_FromConst("Singleplayer");
|
static const String logName = String_FromConst("Singleplayer");
|
||||||
@ -136,7 +125,6 @@ static void SPConnection_BeginConnect(void) {
|
|||||||
RNGState rnd;
|
RNGState rnd;
|
||||||
Chat_SetLogName(&logName);
|
Chat_SetLogName(&logName);
|
||||||
Game_UseCPEBlocks = Game_UseCPE;
|
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;
|
||||||
@ -300,6 +288,14 @@ static void MPConnection_BeginConnect(void) {
|
|||||||
String title; char titleBuffer[STRING_SIZE];
|
String title; char titleBuffer[STRING_SIZE];
|
||||||
cc_result res;
|
cc_result res;
|
||||||
String_InitArray(title, titleBuffer);
|
String_InitArray(title, titleBuffer);
|
||||||
|
|
||||||
|
/* Default block permissions (in case server supports SetBlockPermissions but doesn't send) */
|
||||||
|
Blocks.CanPlace[BLOCK_AIR] = false; Blocks.CanDelete[BLOCK_AIR] = false;
|
||||||
|
Blocks.CanPlace[BLOCK_LAVA] = false; Blocks.CanDelete[BLOCK_LAVA] = false;
|
||||||
|
Blocks.CanPlace[BLOCK_WATER] = false; Blocks.CanDelete[BLOCK_WATER] = false;
|
||||||
|
Blocks.CanPlace[BLOCK_STILL_LAVA] = false; Blocks.CanDelete[BLOCK_STILL_LAVA] = false;
|
||||||
|
Blocks.CanPlace[BLOCK_STILL_WATER] = false; Blocks.CanDelete[BLOCK_STILL_WATER] = false;
|
||||||
|
Blocks.CanPlace[BLOCK_BEDROCK] = false; Blocks.CanDelete[BLOCK_BEDROCK] = false;
|
||||||
|
|
||||||
res = Socket_Create(&net_socket);
|
res = Socket_Create(&net_socket);
|
||||||
if (res) { MPConnection_FailConnect(res); return; }
|
if (res) { MPConnection_FailConnect(res); return; }
|
||||||
@ -493,12 +489,9 @@ static void OnNewMap(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void OnReset(void) {
|
static void OnReset(void) {
|
||||||
if (Server.IsSinglePlayer) {
|
if (Server.IsSinglePlayer) return;
|
||||||
SPConnection_ResetBlockPerms();
|
net_writeFailed = false;
|
||||||
} else {
|
OnFree();
|
||||||
net_writeFailed = false;
|
|
||||||
OnFree();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void OnInit(void) {
|
static void OnInit(void) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user