mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-16 19:15:14 -04:00
Bugfixes
This commit is contained in:
parent
ca000b317c
commit
f07171381c
@ -654,21 +654,33 @@ void Inflate_Process(InflateState* state) {
|
||||
|
||||
ReturnCode Inflate_StreamRead(Stream* stream, UInt8* data, UInt32 count, UInt32* modified) {
|
||||
InflateState* state = (InflateState*)stream->Meta_Inflate;
|
||||
if (state->AvailIn == 0) {
|
||||
/* Fully used up input buffer. Cycle back to start. */
|
||||
if (state->NextIn == INFLATE_MAX_INPUT) state->NextIn = 0;
|
||||
|
||||
UInt8* ptr = &state->Input[state->NextIn];
|
||||
UInt32 read, remaining = INFLATE_MAX_INPUT - state->NextIn;
|
||||
ReturnCode code = state->Source->Read(state->Source, ptr, remaining, &read);
|
||||
if (code != 0) { *modified = 0; return code; }
|
||||
state->AvailIn += read;
|
||||
}
|
||||
|
||||
*modified = 0;
|
||||
state->Output = data;
|
||||
state->AvailOut = count;
|
||||
Inflate_Process(state);
|
||||
*modified = count - state->AvailOut;
|
||||
|
||||
while (state->AvailOut > 0) {
|
||||
if (state->State == INFLATE_STATE_DONE) break;
|
||||
if (state->AvailIn == 0) {
|
||||
/* Fully used up input buffer. Cycle back to start. */
|
||||
if (state->NextIn == INFLATE_MAX_INPUT) state->NextIn = 0;
|
||||
|
||||
UInt8* ptr = &state->Input[state->NextIn];
|
||||
UInt32 read, remaining = INFLATE_MAX_INPUT - state->NextIn;
|
||||
ReturnCode code = state->Source->Read(state->Source, ptr, remaining, &read);
|
||||
|
||||
/* Did we fail to read in more input data? */
|
||||
/* If there's a few bits of data in the bit buffer it doesn't matter since Inflate_Process
|
||||
/* would have already processed as much as it possibly could already */
|
||||
/* TODO: Is this assumption about bit buffer right */
|
||||
if (code != 0 || read == 0) return code;
|
||||
state->AvailIn += read;
|
||||
}
|
||||
|
||||
/* Reading data reduces available out */
|
||||
UInt32 preAvailOut = state->AvailOut;
|
||||
Inflate_Process(state);
|
||||
*modified += (preAvailOut - state->AvailOut);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -481,7 +481,7 @@ void Player_MakeNameTexture(Player* player) {
|
||||
Drawer2D_Begin(&bmp);
|
||||
|
||||
Drawer2D_Cols[0xFF] = PackedCol_Create3(80, 80, 80);
|
||||
String_Append(&shadowName, 0xFF);
|
||||
String_AppendConst(&shadowName, "&\xFF");
|
||||
String_AppendColorless(&shadowName, &displayName);
|
||||
args.Text = shadowName;
|
||||
Drawer2D_DrawText(&args, 3, 3);
|
||||
|
@ -274,7 +274,6 @@ UInt32 Nbt_ReadString(Stream* stream, UInt8* strBuffer) {
|
||||
return i;
|
||||
}
|
||||
|
||||
const UInt8* tagTypes[20] = { "END","INT8","INT16","INT32","INT64","REAL32","REAL64","INT8_ARRAY","STRING","LIST","COMPOUND","INT32_ARRAY" };
|
||||
typedef bool (*Nbt_Callback)(NbtTag* tag);
|
||||
void Nbt_ReadTag(UInt8 typeId, bool readTagName, Stream* stream, NbtTag* parent, Nbt_Callback callback) {
|
||||
if (typeId == NBT_TAG_END) return;
|
||||
@ -285,21 +284,6 @@ void Nbt_ReadTag(UInt8 typeId, bool readTagName, Stream* stream, NbtTag* parent,
|
||||
tag.NameSize = readTagName ? Nbt_ReadString(stream, tag.NameBuffer) : 0;
|
||||
tag.DataSize = 0;
|
||||
|
||||
UInt8 msgBuffer[String_BufferSize(STRING_SIZE * 2)];
|
||||
String msg = String_InitAndClearArray(msgBuffer);
|
||||
|
||||
while (parent != NULL) {
|
||||
parent = parent->Parent;
|
||||
String_AppendConst(&msg, " ");
|
||||
}
|
||||
|
||||
String name = { tag.NameBuffer, tag.NameSize, tag.NameSize };
|
||||
String_AppendString(&msg, &name);
|
||||
String_AppendConst(&msg, " (TAG_");
|
||||
String_AppendConst(&msg, tagTypes[typeId]);
|
||||
String_AppendConst(&msg, ")\r\n");
|
||||
Platform_Log(&msg);
|
||||
|
||||
UInt8 childTagId;
|
||||
UInt32 i, count;
|
||||
|
||||
@ -361,17 +345,6 @@ void Nbt_ReadTag(UInt8 typeId, bool readTagName, Stream* stream, NbtTag* parent,
|
||||
bool processed = callback(&tag);
|
||||
/* don't leak memory for unprocessed tags */
|
||||
if (!processed && tag.DataSize >= NBT_SMALL_SIZE) Platform_MemFree(&tag.DataBig);
|
||||
|
||||
String_Clear(&msg);
|
||||
parent = tag.Parent;
|
||||
while (parent != NULL) {
|
||||
parent = parent->Parent;
|
||||
String_AppendConst(&msg, " ");
|
||||
}
|
||||
String_AppendConst(&msg, " -- processed: ");
|
||||
String_AppendBool(&msg, processed);
|
||||
String_AppendConst(&msg, ")\r\n");
|
||||
Platform_Log(&msg);
|
||||
}
|
||||
|
||||
bool IsTag(NbtTag* tag, const UInt8* tagName) {
|
||||
|
@ -478,6 +478,7 @@ void Game_Load(void) {
|
||||
ServerConnection_InitMultiplayer();
|
||||
}
|
||||
comp = ServerConnection_MakeComponent(); Game_AddComponent(&comp);
|
||||
String_AppendConst(&ServerConnection_AppName, PROGRAM_APP_NAME);
|
||||
|
||||
Gfx_LostContextFunction = ServerConnection_Tick;
|
||||
Camera_Init();
|
||||
|
@ -430,7 +430,7 @@ void Classic_LevelDataChunk(Stream* stream) {
|
||||
|
||||
Int32 usedLength = Stream_ReadU16_BE(stream);
|
||||
mapPartStream.Meta_Mem_Buffer = stream->Meta_Mem_Buffer;
|
||||
mapPartStream.Meta_Mem_Count = stream->Meta_Mem_Count;
|
||||
mapPartStream.Meta_Mem_Count = usedLength;
|
||||
|
||||
Stream_Skip(stream, 1024);
|
||||
UInt8 value = Stream_ReadU8(stream); /* progress in original classic, but we ignore it */
|
||||
|
@ -47,8 +47,10 @@ int main(int argc, char* argv[]) {
|
||||
}
|
||||
|
||||
String title = String_FromConst(PROGRAM_APP_NAME);
|
||||
argc = 5;
|
||||
char* default_argv[5] = { "path", "UnknownShadow200", "mppass", "127.0.0.1", "25566" };
|
||||
//argc = 5;
|
||||
//char* default_argv[5] = { "path", "UnknownShadow200", "mppass", "127.0.0.1", "25566" };
|
||||
argc = 2;
|
||||
char* default_argv[5] = { "path", "UnknownShadow200" };
|
||||
argv = default_argv;
|
||||
|
||||
if (argc == 1 || argc == 2) {
|
||||
|
@ -1473,7 +1473,7 @@ void DisconnectScreen_Init(GuiElement* elem) {
|
||||
|
||||
void DisconnectScreen_Render(GuiElement* elem, Real64 delta) {
|
||||
DisconnectScreen* screen = (DisconnectScreen*)elem;
|
||||
if (!screen->CanReconnect) {
|
||||
if (screen->CanReconnect) {
|
||||
DisconnectScreen_UpdateDelayLeft(screen, delta);
|
||||
}
|
||||
|
||||
@ -1554,7 +1554,7 @@ Screen* DisconnectScreen_MakeInstance(STRING_PURE String* title, STRING_PURE Str
|
||||
|
||||
String kick = String_FromConst("Kicked ");
|
||||
String ban = String_FromConst("Banned ");
|
||||
screen->CanReconnect = String_StartsWith(&reason, &kick) || String_StartsWith(&reason, &ban);
|
||||
screen->CanReconnect = !(String_StartsWith(&reason, &kick) || String_StartsWith(&reason, &ban));
|
||||
|
||||
Platform_MakeFont(&screen->TitleFont, &Game_FontName, 16, FONT_STYLE_BOLD);
|
||||
Platform_MakeFont(&screen->MessageFont, &Game_FontName, 16, FONT_STYLE_NORMAL);
|
||||
|
@ -970,8 +970,8 @@ void InputWidget_RenderCaret(InputWidget* widget, Real64 delta) {
|
||||
if (!widget->ShowCaret) return;
|
||||
|
||||
widget->CaretAccumulator += delta;
|
||||
Real64 second = widget->CaretAccumulator - (Real64)Math_Floor((Real32)widget->CaretAccumulator);
|
||||
if (second < 0.5) {
|
||||
Real32 second = Math_ModF((Real32)widget->CaretAccumulator, 1.0);
|
||||
if (second < 0.5f) {
|
||||
Texture_RenderShaded(&widget->CaretTex, widget->CaretCol);
|
||||
}
|
||||
}
|
||||
@ -2278,7 +2278,7 @@ void TextGroupWidget_UpdateDimensions(TextGroupWidget* widget) {
|
||||
String TextGroupWidget_UNSAFE_Get(TextGroupWidget* widget, Int32 i) {
|
||||
UInt8* buffer = widget->Buffer + i * TEXTGROUPWIDGET_LEN;
|
||||
UInt16 length = widget->LineLengths[i];
|
||||
return String_Init(widget->Buffer, length, length);
|
||||
return String_Init(buffer, length, length);
|
||||
}
|
||||
|
||||
void TextGroupWidget_GetSelected(TextGroupWidget* widget, STRING_TRANSIENT String* text, Int32 x, Int32 y) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user