mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-15 02:25:32 -04:00
Add World.Loaded variable
This commit is contained in:
parent
0654dc0f41
commit
f7dae6bc72
@ -184,8 +184,7 @@ void Game_Disconnect(const String* title, const String* reason) {
|
|||||||
|
|
||||||
void Game_Reset(void) {
|
void Game_Reset(void) {
|
||||||
struct IGameComponent* comp;
|
struct IGameComponent* comp;
|
||||||
World_Reset();
|
World_NewMap();
|
||||||
Event_RaiseVoid(&WorldEvents.NewMap);
|
|
||||||
|
|
||||||
if (World_TextureUrl.length) {
|
if (World_TextureUrl.length) {
|
||||||
World_TextureUrl.length = 0;
|
World_TextureUrl.length = 0;
|
||||||
|
@ -178,7 +178,7 @@ static void Menu_Remove(void* screen, int i) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void Menu_BeginGen(int width, int height, int length) {
|
static void Menu_BeginGen(int width, int height, int length) {
|
||||||
World_Reset();
|
World_NewMap();
|
||||||
World_SetDimensions(width, height, length);
|
World_SetDimensions(width, height, length);
|
||||||
GeneratingScreen_Show();
|
GeneratingScreen_Show();
|
||||||
}
|
}
|
||||||
|
@ -424,8 +424,7 @@ static void MapState_Read(struct MapState* m) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void Classic_StartLoading(void) {
|
static void Classic_StartLoading(void) {
|
||||||
World_Reset();
|
World_NewMap();
|
||||||
Event_RaiseVoid(&WorldEvents.NewMap);
|
|
||||||
Stream_ReadonlyMemory(&map_part, NULL, 0);
|
Stream_ReadonlyMemory(&map_part, NULL, 0);
|
||||||
|
|
||||||
LoadingScreen_Show(&Server.Name, &Server.MOTD);
|
LoadingScreen_Show(&Server.Name, &Server.MOTD);
|
||||||
|
@ -1346,7 +1346,6 @@ struct Screen* LoadingScreen_UNSAFE_RawPointer = (struct Screen*)&LoadingScreen;
|
|||||||
static void GeneratingScreen_Init(void* screen) {
|
static void GeneratingScreen_Init(void* screen) {
|
||||||
Gen_Done = false;
|
Gen_Done = false;
|
||||||
LoadingScreen_Init(screen);
|
LoadingScreen_Init(screen);
|
||||||
Event_RaiseVoid(&WorldEvents.NewMap);
|
|
||||||
|
|
||||||
Gen_Blocks = (BlockRaw*)Mem_TryAlloc(World.Volume, 1);
|
Gen_Blocks = (BlockRaw*)Mem_TryAlloc(World.Volume, 1);
|
||||||
if (!Gen_Blocks) {
|
if (!Gen_Blocks) {
|
||||||
|
@ -49,6 +49,12 @@ void World_Reset(void) {
|
|||||||
Env_Reset();
|
Env_Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void World_NewMap(void) {
|
||||||
|
World_Reset();
|
||||||
|
World.Loaded = false;
|
||||||
|
Event_RaiseVoid(&WorldEvents.NewMap);
|
||||||
|
}
|
||||||
|
|
||||||
void World_SetNewMap(BlockRaw* blocks, int width, int height, int length) {
|
void World_SetNewMap(BlockRaw* blocks, int width, int height, int length) {
|
||||||
World_SetDimensions(width, height, length);
|
World_SetDimensions(width, height, length);
|
||||||
World.Blocks = blocks;
|
World.Blocks = blocks;
|
||||||
@ -65,6 +71,7 @@ void World_SetNewMap(BlockRaw* blocks, int width, int height, int length) {
|
|||||||
if (Env.EdgeHeight == -1) { Env.EdgeHeight = height / 2; }
|
if (Env.EdgeHeight == -1) { Env.EdgeHeight = height / 2; }
|
||||||
if (Env.CloudsHeight == -1) { Env.CloudsHeight = height + 2; }
|
if (Env.CloudsHeight == -1) { Env.CloudsHeight = height + 2; }
|
||||||
GenerateNewUuid();
|
GenerateNewUuid();
|
||||||
|
World.Loaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
CC_NOINLINE void World_SetDimensions(int width, int height, int length) {
|
CC_NOINLINE void World_SetDimensions(int width, int height, int length) {
|
||||||
|
@ -39,11 +39,17 @@ CC_VAR extern struct _WorldData {
|
|||||||
/* e.g. this will be 255 if only 8 bit blocks are used */
|
/* e.g. this will be 255 if only 8 bit blocks are used */
|
||||||
int IDMask;
|
int IDMask;
|
||||||
#endif
|
#endif
|
||||||
|
/* Whether the world has finished loading/generating. */
|
||||||
|
/* NOTE: Blocks may still be NULL. (e.g. error during loading) */
|
||||||
|
cc_bool Loaded;
|
||||||
} World;
|
} World;
|
||||||
extern String World_TextureUrl;
|
extern String World_TextureUrl;
|
||||||
|
|
||||||
/* Frees the blocks array, sets dimensions to 0, resets environment to default. */
|
/* Frees the blocks array, sets dimensions to 0, resets environment to default. */
|
||||||
CC_API void World_Reset(void);
|
void World_Reset(void);
|
||||||
|
/* Sets up state and raises WorldEvents.NewMap event */
|
||||||
|
/* NOTE: This implicitly calls World_Reset. */
|
||||||
|
CC_API void World_NewMap(void);
|
||||||
/* Sets the blocks array and dimensions of the map. */
|
/* Sets the blocks array and dimensions of the map. */
|
||||||
/* May also sets some environment settings like border/clouds height, if they are -1 */
|
/* May also sets some environment settings like border/clouds height, if they are -1 */
|
||||||
CC_API void World_SetNewMap(BlockRaw* blocks, int width, int height, int length);
|
CC_API void World_SetNewMap(BlockRaw* blocks, int width, int height, int length);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user