Fix web client not compiling

This commit is contained in:
UnknownShadow200 2019-05-20 22:48:30 +10:00
parent e6f03c40ae
commit 2237175da1
7 changed files with 41 additions and 42 deletions

View File

@ -192,22 +192,22 @@ void Chat_AddRaw(const char* raw) {
}
void Chat_Add(const String* text) { Chat_AddOf(text, MSG_TYPE_NORMAL); }
void Chat_AddOf(const String* text, MsgType type) {
Event_RaiseChat(&ChatEvents.ChatReceived, text, type);
void Chat_AddOf(const String* text, int msgType) {
Event_RaiseChat(&ChatEvents.ChatReceived, text, msgType);
if (type == MSG_TYPE_NORMAL) {
if (msgType == MSG_TYPE_NORMAL) {
StringsBuffer_Add(&Chat_Log, text);
Chat_AppendLog(text);
Chat_AppendLogTime();
} else if (type >= MSG_TYPE_STATUS_1 && type <= MSG_TYPE_STATUS_3) {
String_Copy(&Chat_Status[type - MSG_TYPE_STATUS_1], text);
} else if (type >= MSG_TYPE_BOTTOMRIGHT_1 && type <= MSG_TYPE_BOTTOMRIGHT_3) {
String_Copy(&Chat_BottomRight[type - MSG_TYPE_BOTTOMRIGHT_1], text);
} else if (type == MSG_TYPE_ANNOUNCEMENT) {
} else if (msgType >= MSG_TYPE_STATUS_1 && msgType <= MSG_TYPE_STATUS_3) {
String_Copy(&Chat_Status[msgType - MSG_TYPE_STATUS_1], text);
} else if (msgType >= MSG_TYPE_BOTTOMRIGHT_1 && msgType <= MSG_TYPE_BOTTOMRIGHT_3) {
String_Copy(&Chat_BottomRight[msgType - MSG_TYPE_BOTTOMRIGHT_1], text);
} else if (msgType == MSG_TYPE_ANNOUNCEMENT) {
String_Copy(&Chat_Announcement, text);
Chat_AnnouncementReceived = DateTime_CurrentUTC_MS();
} else if (type >= MSG_TYPE_CLIENTSTATUS_1 && type <= MSG_TYPE_CLIENTSTATUS_3) {
String_Copy(&Chat_ClientStatus[type - MSG_TYPE_CLIENTSTATUS_1], text);
} else if (msgType >= MSG_TYPE_CLIENTSTATUS_1 && msgType <= MSG_TYPE_CLIENTSTATUS_3) {
String_Copy(&Chat_ClientStatus[msgType - MSG_TYPE_CLIENTSTATUS_1], text);
}
}

View File

@ -9,7 +9,7 @@
struct IGameComponent;
extern struct IGameComponent Chat_Component;
typedef enum MsgType_ {
enum MsgType {
MSG_TYPE_NORMAL = 0,
MSG_TYPE_STATUS_1 = 1,
MSG_TYPE_STATUS_2 = 2,
@ -20,8 +20,8 @@ typedef enum MsgType_ {
MSG_TYPE_ANNOUNCEMENT = 100,
MSG_TYPE_CLIENTSTATUS_1 = 256, /* Cuboid messages */
MSG_TYPE_CLIENTSTATUS_2 = 257, /* Clipboard invalid character */
MSG_TYPE_CLIENTSTATUS_3 = 258 /* Tab list matching names*/
} MsgType;
MSG_TYPE_CLIENTSTATUS_3 = 258 /* Tab list matching names */
};
extern String Chat_Status[3], Chat_BottomRight[3], Chat_ClientStatus[3], Chat_Announcement;
extern StringsBuffer Chat_Log, Chat_InputLog;
@ -59,7 +59,7 @@ CC_API void Chat_Add(const String* text);
/* Adds a chat message, raising ChatEvents.ChatReceived event. */
/* MSG_TYPE_NORMAL is usually used for player chat and command messages. */
/* Other message types are usually used for info/status messages. */
CC_API void Chat_AddOf(const String* text, MsgType type);
CC_API void Chat_AddOf(const String* text, int msgType);
/* Shorthand for Chat_AddOf(String_FromReadonly(raw), MSG_TYPE_NORMAL) */
void Chat_AddRaw(const char* raw);

View File

@ -763,7 +763,7 @@ struct WaitData {
};
void* Waitable_Create(void) {
struct WaitData* ptr = Mem_Alloc(1, sizeof(struct WaitData), "waitable");
struct WaitData* ptr = (struct WaitData*)Mem_Alloc(1, sizeof(struct WaitData), "waitable");
int res;
res = pthread_cond_init(&ptr->cond, NULL);

View File

@ -18,16 +18,15 @@
#include "Options.h"
#include "Logger.h"
#ifndef CC_BUILD_WEB
#define LIQUID_ANIM_MAX 64
#define WATER_TEX_LOC 14
#define LAVA_TEX_LOC 30
#define LAVA_TEX_LOC 30
#ifndef CC_BUILD_WEB
/* Based off the incredible work from https://dl.dropboxusercontent.com/u/12694594/lava.txt
mirrored at https://github.com/UnknownShadow200/ClassicalSharp/wiki/Minecraft-Classic-lava-animation-algorithm
Water animation originally written by cybertoon, big thanks!
*/
/*########################################################################################################################*
*-----------------------------------------------------Lava animation------------------------------------------------------*
*#########################################################################################################################*/
@ -516,25 +515,25 @@ void Atlas_Free(void) {
*#########################################################################################################################*/
/* Because I didn't store milliseconds in original C# client */
#define TEXCACHE_TICKS_PER_MS 10000
static struct EntryList cache_accepted, cache_denied, cache_eTags, cache_lastModified;
static struct EntryList acceptedList, deniedList, etagCache, lastModifiedCache;
void TextureCache_Init(void) {
EntryList_Init(&cache_accepted, "texturecache", "acceptedurls.txt", ' ');
EntryList_Init(&cache_denied, "texturecache", "deniedurls.txt", ' ');
EntryList_Init(&cache_eTags, "texturecache", "etags.txt", ' ');
EntryList_Init(&cache_lastModified, "texturecache", "lastmodified.txt", ' ');
EntryList_Init(&acceptedList, "texturecache", "acceptedurls.txt", ' ');
EntryList_Init(&deniedList, "texturecache", "deniedurls.txt", ' ');
EntryList_Init(&etagCache, "texturecache", "etags.txt", ' ');
EntryList_Init(&lastModifiedCache, "texturecache", "lastmodified.txt", ' ');
}
bool TextureCache_HasAccepted(const String* url) { return EntryList_Find(&cache_accepted, url) >= 0; }
bool TextureCache_HasDenied(const String* url) { return EntryList_Find(&cache_denied, url) >= 0; }
bool TextureCache_HasAccepted(const String* url) { return EntryList_Find(&acceptedList, url) >= 0; }
bool TextureCache_HasDenied(const String* url) { return EntryList_Find(&deniedList, url) >= 0; }
void TextureCache_Accept(const String* url) {
EntryList_Set(&cache_accepted, url, &String_Empty);
EntryList_Save(&cache_accepted);
EntryList_Set(&acceptedList, url, &String_Empty);
EntryList_Save(&acceptedList);
}
void TextureCache_Deny(const String* url) {
EntryList_Set(&cache_denied, url, &String_Empty);
EntryList_Save(&cache_denied);
EntryList_Set(&deniedList, url, &String_Empty);
EntryList_Save(&deniedList);
}
CC_NOINLINE static void TextureCache_MakePath(String* path, const String* url) {
@ -581,7 +580,7 @@ void TextureCache_GetLastModified(const String* url, TimeMS* time) {
ReturnCode res;
String_InitArray(entry, entryBuffer);
TexturePack_GetFromTags(url, &entry, &cache_lastModified);
TexturePack_GetFromTags(url, &entry, &lastModifiedCache);
if (entry.length && Convert_ParseUInt64(&entry, time)) {
*time /= TEXCACHE_TICKS_PER_MS;
@ -595,7 +594,7 @@ void TextureCache_GetLastModified(const String* url, TimeMS* time) {
}
void TextureCache_GetETag(const String* url, String* etag) {
TexturePack_GetFromTags(url, etag, &cache_eTags);
TexturePack_GetFromTags(url, etag, &etagCache);
}
void TextureCache_Set(const String* url, const void* data, uint32_t length) {
@ -621,7 +620,7 @@ CC_NOINLINE static void TextureCache_SetEntry(const String* url, const String* d
void TextureCache_SetETag(const String* url, const String* etag) {
if (!etag->length) return;
TextureCache_SetEntry(url, etag, &cache_eTags);
TextureCache_SetEntry(url, etag, &etagCache);
}
void TextureCache_SetLastModified(const String* url, const TimeMS* lastModified) {
@ -631,7 +630,7 @@ void TextureCache_SetLastModified(const String* url, const TimeMS* lastModified)
String_InitArray(data, dataBuffer);
String_AppendUInt64(&data, ticks);
TextureCache_SetEntry(url, &data, &cache_lastModified);
TextureCache_SetEntry(url, &data, &lastModifiedCache);
}

View File

@ -196,17 +196,17 @@ const uint32_t Utils_Crc32Table[256] = {
0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D,
};
void Utils_Resize(void** buffer, uint32_t* maxElems, uint32_t elemSize, uint32_t defElems, uint32_t expandElems) {
void Utils_Resize(void** buffer, int* capacity, uint32_t elemSize, int defCapacity, int expandElems) {
/* We use a statically allocated buffer initally, so can't realloc first time */
uint32_t curElems = *maxElems, elems = curElems + expandElems;
*maxElems = elems;
int curCapacity = *capacity, newCapacity = curCapacity + expandElems;
*capacity = newCapacity;
if (curElems <= defElems) {
void* resized = Mem_Alloc(elems, elemSize, "initing array");
Mem_Copy(resized, *buffer, curElems * elemSize);
if (curCapacity <= defCapacity) {
void* resized = Mem_Alloc(newCapacity, elemSize, "initing array");
Mem_Copy(resized, *buffer, (uint32_t)curCapacity * elemSize);
*buffer = resized;
} else {
*buffer = Mem_Realloc(*buffer, elems, elemSize, "resizing array");
*buffer = Mem_Realloc(*buffer, newCapacity, elemSize, "resizing array");
}
}

View File

@ -45,7 +45,7 @@ uint32_t Utils_CRC32(const uint8_t* data, uint32_t length);
/* CRC32 lookup table, for faster CRC32 calculations. */
/* NOTE: This cannot be just indexed by byte value - see Utils_CRC32 implementation. */
extern const uint32_t Utils_Crc32Table[256];
CC_NOINLINE void Utils_Resize(void** buffer, uint32_t* maxElems, uint32_t elemSize, uint32_t defElems, uint32_t expandElems);
CC_NOINLINE void Utils_Resize(void** buffer, int* capacity, uint32_t elemSize, int defCapacity, int expandElems);
CC_NOINLINE bool Utils_ParseIP(const String* ip, uint8_t* data);
/* Converts blocks of 3 bytes into 4 ASCII characters. (pads if needed) */

View File

@ -1606,7 +1606,7 @@ void Window_InitRaw(Bitmap* bmp) {
if (win_image) XFree(win_image);
Mem_Free(bmp->Scan0);
bmp->Scan0 = Mem_Alloc(bmp->Width * bmp->Height, 4, "window pixels");
bmp->Scan0 = (uint8_t*)Mem_Alloc(bmp->Width * bmp->Height, 4, "window pixels");
win_image = XCreateImage(win_display, win_visual.visual,
win_visual.depth, ZPixmap, 0, bmp->Scan0,