mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-11 16:45:48 -04:00
Improve error message for when blocks array size doesn't equal volume of map
This commit is contained in:
parent
f7c81da3c9
commit
19e7d474fe
@ -383,7 +383,6 @@ void LBackend_CheckboxDraw(struct LCheckbox* w) {
|
||||
*------------------------------------------------------InputWidget--------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
static TimeMS caretStart;
|
||||
static cc_bool lastCaretShow;
|
||||
static Rect2D caretRect, lastCaretRect;
|
||||
#define Rect2D_Equals(a, b) a.X == b.X && a.Y == b.Y && a.Width == b.Width && a.Height == b.Height
|
||||
|
||||
|
@ -132,6 +132,7 @@ static const struct LWidgetVTABLE lbutton_VTABLE = {
|
||||
};
|
||||
void LButton_Init(struct LButton* w, int width, int height, const char* text) {
|
||||
w->VTABLE = &lbutton_VTABLE;
|
||||
w->type = LWIDGET_BUTTON;
|
||||
w->tabSelectable = true;
|
||||
LBackend_ButtonInit(w, width, height);
|
||||
LButton_SetConst(w, text);
|
||||
@ -159,6 +160,7 @@ static const struct LWidgetVTABLE lcheckbox_VTABLE = {
|
||||
};
|
||||
void LCheckbox_Init(struct LCheckbox* w, const char* text) {
|
||||
w->VTABLE = &lcheckbox_VTABLE;
|
||||
w->type = LWIDGET_CHECKBOX;
|
||||
w->tabSelectable = true;
|
||||
|
||||
w->text = String_FromReadonly(text);
|
||||
@ -322,6 +324,7 @@ static const struct LWidgetVTABLE linput_VTABLE = {
|
||||
};
|
||||
void LInput_Init(struct LInput* w, int width, const char* hintText) {
|
||||
w->VTABLE = &linput_VTABLE;
|
||||
w->type = LWIDGET_INPUT;
|
||||
w->tabSelectable = true;
|
||||
w->opaque = true;
|
||||
String_InitArray(w->text, w->_textBuffer);
|
||||
@ -376,6 +379,7 @@ static const struct LWidgetVTABLE llabel_VTABLE = {
|
||||
};
|
||||
void LLabel_Init(struct LLabel* w, const char* text) {
|
||||
w->VTABLE = &llabel_VTABLE;
|
||||
w->type = LWIDGET_LABEL;
|
||||
|
||||
String_InitArray(w->text, w->_textBuffer);
|
||||
LBackend_LabelInit(w);
|
||||
@ -410,6 +414,7 @@ static const struct LWidgetVTABLE lline_VTABLE = {
|
||||
};
|
||||
void LLine_Init(struct LLine* w, int width) {
|
||||
w->VTABLE = &lline_VTABLE;
|
||||
w->type = LWIDGET_LINE;
|
||||
LBackend_LineInit(w, width);
|
||||
}
|
||||
|
||||
@ -435,6 +440,7 @@ static const struct LWidgetVTABLE lslider_VTABLE = {
|
||||
};
|
||||
void LSlider_Init(struct LSlider* w, int width, int height, BitmapCol color) {
|
||||
w->VTABLE = &lslider_VTABLE;
|
||||
w->type = LWIDGET_SLIDER;
|
||||
w->color = color;
|
||||
w->opaque = true;
|
||||
LBackend_SliderInit(w, width, height);
|
||||
@ -626,6 +632,7 @@ static const struct LWidgetVTABLE ltable_VTABLE = {
|
||||
void LTable_Init(struct LTable* w, struct FontDesc* rowFont) {
|
||||
int i;
|
||||
w->VTABLE = <able_VTABLE;
|
||||
w->type = LWIDGET_TABLE;
|
||||
w->columns = tableColumns;
|
||||
w->numColumns = Array_Elems(tableColumns);
|
||||
w->rowFont = rowFont;
|
||||
|
@ -6,6 +6,10 @@
|
||||
Copyright 2014-2021 ClassiCube | Licensed under BSD-3
|
||||
*/
|
||||
struct FontDesc;
|
||||
enum LWIDGET_TYPE {
|
||||
LWIDGET_BUTTON, LWIDGET_CHECKBOX, LWIDGET_INPUT,
|
||||
LWIDGET_LABEL, LWIDGET_LINE, LWIDGET_SLIDER, LWIDGET_TABLE
|
||||
};
|
||||
|
||||
struct LWidgetVTABLE {
|
||||
/* Called to draw contents of this widget */
|
||||
@ -41,6 +45,7 @@ struct LWidgetVTABLE {
|
||||
cc_uint8 horAnchor, verAnchor; /* Specifies the reference point for when this widget is resized */ \
|
||||
cc_bool dirty; /* Whether this widget needs to be redrawn */ \
|
||||
cc_bool opaque; /* Whether this widget completely obscures background behind it */ \
|
||||
cc_uint8 type; /* Type of this widget */ \
|
||||
int xOffset, yOffset; /* Offset from the reference point */ \
|
||||
void (*OnClick)(void* widget); /* Called when widget is clicked */ \
|
||||
void (*OnHover)(void* widget); /* Called when widget is hovered over */ \
|
||||
|
@ -533,7 +533,7 @@ static void Classic_LevelDataChunk(cc_uint8* data) {
|
||||
}
|
||||
|
||||
static void Classic_LevelFinalise(cc_uint8* data) {
|
||||
int width, height, length;
|
||||
int width, height, length, volume;
|
||||
cc_uint64 end;
|
||||
int delta;
|
||||
|
||||
@ -550,16 +550,17 @@ static void Classic_LevelFinalise(cc_uint8* data) {
|
||||
width = Stream_GetU16_BE(data + 0);
|
||||
height = Stream_GetU16_BE(data + 2);
|
||||
length = Stream_GetU16_BE(data + 4);
|
||||
volume = width * height * length;
|
||||
|
||||
if (map_volume != (width * height * length)) {
|
||||
Chat_AddRaw("&cFailed to load map, try joining a different map");
|
||||
Chat_AddRaw(" &cBlocks array size does not match volume of map");
|
||||
FreeMapStates();
|
||||
}
|
||||
if (!map.blocks) {
|
||||
Chat_AddRaw("&cFailed to load map, try joining a different map");
|
||||
Chat_AddRaw(" &cAttempted to load map without a Blocks array");
|
||||
}
|
||||
if (map_volume != volume) {
|
||||
Chat_AddRaw("&cFailed to load map, try joining a different map");
|
||||
Chat_Add2( " &cBlocks array size (%i) does not match volume of map (%i)", &map_volume, &volume);
|
||||
FreeMapStates();
|
||||
}
|
||||
|
||||
#ifdef EXTENDED_BLOCKS
|
||||
/* defer allocation of second map array if possible */
|
||||
|
Loading…
x
Reference in New Issue
Block a user