Permalink
Browse files

you guessed it, even more

  • Loading branch information...
UnknownShadow200 committed Nov 5, 2018
1 parent feaf213 commit aeec580a129098f63ba938e9960adbad974787ce
Showing with 182 additions and 159 deletions.
  1. +15 −14 src/Animations.c
  2. +14 −12 src/AsyncDownloader.c
  3. +3 −2 src/Audio.c
  4. +5 −5 src/Block.c
  5. +9 −8 src/Chat.c
  6. +5 −5 src/Entity.c
  7. +12 −9 src/ErrorHandler.c
  8. +7 −7 src/Game.c
  9. +6 −6 src/Input.c
  10. +11 −9 src/Menus.c
  11. +9 −9 src/Options.c
  12. +11 −12 src/PacketHandlers.c
  13. +10 −8 src/Platform.c
  14. +5 −4 src/Program.c
  15. +18 −16 src/Screens.c
  16. +18 −14 src/TexturePack.c
  17. +24 −19 src/Widgets.c
@@ -156,18 +156,19 @@ bool anims_validated, anims_useLavaAnim, anims_useWaterAnim;
#define ANIM_MIN_ARGS 7
static void Animations_ReadDescription(struct Stream* stream, const String* path) {
char lineBuffer[STRING_SIZE * 2];
String line = String_FromArray(lineBuffer);
String line; char lineBuffer[STRING_SIZE * 2];
String parts[ANIM_MIN_ARGS];
int count;
struct AnimationData data = { 0 };
uint8_t tileX, tileY;
/* ReadLine reads single byte at a time */
uint8_t buffer[2048]; struct Stream buffered;
uint8_t buffer[2048];
struct Stream buffered;
ReturnCode res;
Stream_ReadonlyBuffered(&buffered, stream, buffer, sizeof(buffer));
String_InitArray(line, lineBuffer);
/* ReadLine reads single byte at a time */
Stream_ReadonlyBuffered(&buffered, stream, buffer, sizeof(buffer));
for (;;) {
res = Stream_ReadLine(&buffered, &line);
@@ -244,25 +245,25 @@ static void Animations_Draw(struct AnimationData* data, TextureLoc texLoc, int s
}
static void Animations_Apply(struct AnimationData* data) {
TextureLoc texLoc;
TextureLoc loc;
data->Tick--;
if (data->Tick >= 0) return;
data->State++;
data->State %= data->StatesCount;
data->Tick = data->TickDelay;
texLoc = data->TexLoc;
if (texLoc == 30 && anims_useLavaAnim) return;
if (texLoc == 14 && anims_useWaterAnim) return;
Animations_Draw(data, texLoc, data->FrameSize);
loc = data->TexLoc;
if (loc == 30 && anims_useLavaAnim) return;
if (loc == 14 && anims_useWaterAnim) return;
Animations_Draw(data, loc, data->FrameSize);
}
static bool Animations_IsDefaultZip(void) {
char texPackBuffer[STRING_SIZE];
String texPack = String_FromArray(texPackBuffer);
String texPack; char texPackBuffer[STRING_SIZE];
if (World_TextureUrl.length) return false;
String_InitArray(texPack, texPackBuffer);
Options_Get(OPT_DEFAULT_TEX_PACK, &texPack, "default.zip");
return String_CaselessEqualsConst(&texPack, "default.zip");
}
@@ -81,21 +81,23 @@ bool KeepAlive;
static void AsyncDownloader_Add(const String* url, bool priority, const String* id, uint8_t type, TimeMS* lastModified, const String* etag, const String* data) {
struct AsyncRequest req = { 0 };
String reqUrl = String_FromArray(req.URL);
String reqID = String_FromArray(req.ID);
String reqEtag = String_FromArray(req.Etag);
String reqUrl, reqID, reqEtag;
Mutex_Lock(async_pendingMutex);
{
String_Copy(&reqUrl, url);
String_Copy(&reqID, id);
req.RequestType = type;
Platform_Log2("Adding %s (type %b)", &reqUrl, &type);
String_InitArray(reqUrl, req.URL);
String_Copy(&reqUrl, url);
String_InitArray(reqID, req.ID);
String_Copy(&reqID, id);
req.RequestType = type;
Platform_Log2("Adding %s (type %b)", &reqUrl, &type);
if (lastModified) { req.LastModified = *lastModified; }
if (etag) { String_Copy(&reqEtag, etag); }
/* request.Data = data; TODO: Implement this. do we need to copy or expect caller to malloc it? */
String_InitArray(reqEtag, req.Etag);
if (lastModified) { req.LastModified = *lastModified; }
if (etag) { String_Copy(&reqEtag, etag); }
/* request.Data = data; TODO: Implement this. do we need to copy or expect caller to malloc it? */
Mutex_Lock(async_pendingMutex);
{
req.TimeAdded = DateTime_CurrentUTC_MS();
if (priority) {
AsyncRequestList_Prepend(&async_pending, &req);
@@ -100,12 +100,13 @@ static ReturnCode Sound_ReadWaveData(struct Stream* stream, struct Sound* snd) {
}
static ReturnCode Sound_ReadWave(const String* filename, struct Sound* snd) {
char pathBuffer[FILENAME_SIZE];
String path = String_FromArray(pathBuffer);
struct Stream stream;
ReturnCode res;
String path; char pathBuffer[FILENAME_SIZE];
String_InitArray(path, pathBuffer);
String_Format2(&path, "audio%r%s", &Directory_Separator, filename);
res = Stream_OpenFile(&stream, &path);
if (res) return res;
@@ -473,14 +473,14 @@ void Block_UpdateCulling(BlockID block) {
*-------------------------------------------------------AutoRotate--------------------------------------------------------*
*#########################################################################################################################*/
static BlockID AutoRotate_Find(BlockID block, const String* name, const char* suffix) {
char buffer[STRING_SIZE * 2];
String temp = String_FromArray(buffer);
int rotated;
String str; char strBuffer[STRING_SIZE * 2];
String_AppendString(&temp, name);
String_AppendConst(&temp, suffix);
String_InitArray(str, strBuffer);
String_AppendString(&str, name);
String_AppendConst(&str, suffix);
rotated = Block_FindID(&temp);
rotated = Block_FindID(&str);
return rotated == -1 ? block : (BlockID)rotated;
}
@@ -118,14 +118,13 @@ static void Chat_OpenLog(DateTime* now) {
}
static void Chat_AppendLog(const String* text) {
char strBuffer[STRING_SIZE * 2];
String str = String_FromArray(strBuffer);
DateTime now;
ReturnCode res;
if (!Chat_LogName.length || !Game_ChatLogging) return;
String str; char strBuffer[STRING_SIZE * 2];
if (!Chat_LogName.length || !Game_ChatLogging) return;
DateTime_CurrentLocal(&now);
if (now.Day != ChatLog_LastLogDate.Day || now.Month != ChatLog_LastLogDate.Month || now.Year != ChatLog_LastLogDate.Year) {
Chat_CloseLog();
Chat_OpenLog(&now);
@@ -135,6 +134,7 @@ static void Chat_AppendLog(const String* text) {
if (!Chat_LogStream.Meta.File) return;
/* [HH:mm:ss] text */
String_InitArray(str, strBuffer);
String_Format3(&str, "[%p2:%p2:%p2] ", &now.Hour, &now.Minute, &now.Second);
String_AppendColorless(&str, text);
@@ -166,8 +166,9 @@ void Chat_Add3(const char* format, const void* a1, const void* a2, const void* a
Chat_Add4(format, a1, a2, a3, NULL);
}
void Chat_Add4(const char* format, const void* a1, const void* a2, const void* a3, const void* a4) {
char msgBuffer[STRING_SIZE * 2];
String msg = String_FromArray(msgBuffer);
String msg; char msgBuffer[STRING_SIZE * 2];
String_InitArray(msg, msgBuffer);
String_Format4(&msg, format, a1, a2, a3, a4);
Chat_AddOf(&msg, MSG_TYPE_NORMAL);
}
@@ -473,8 +474,8 @@ static void CuboidCommand_DoCuboid(void) {
}
static void CuboidCommand_BlockChanged(void* obj, Vector3I coords, BlockID old, BlockID now) {
char msgBuffer[STRING_SIZE];
String msg = String_FromArray(msgBuffer);
String msg; char msgBuffer[STRING_SIZE];
String_InitArray(msg, msgBuffer);
if (cuboid_mark1.X == Int32_MaxValue) {
cuboid_mark1 = coords;
@@ -864,7 +864,7 @@ void LocalPlayer_Tick(struct Entity* e, double delta) {
AnimatedComp_Update(e, p->Interp.Prev.Pos, p->Interp.Next.Pos, delta);
TiltComp_Update(&p->Tilt, delta);
Player_CheckSkin(&p->Base);
Player_CheckSkin((struct Player*)p);
SoundComp_Tick(wasOnGround);
}
@@ -931,7 +931,7 @@ struct EntityVTABLE localPlayer_VTABLE = {
void LocalPlayer_Init(void) {
struct LocalPlayer* p = &LocalPlayer_Instance;
Player_Init(&p->Base);
Player_SetName(&p->Base, &Game_Username, &Game_Username);
Player_SetName((struct Player*)p, &Game_Username, &Game_Username);
p->Collisions.Entity = &p->Base;
HacksComp_Init(&p->Hacks);
@@ -1070,7 +1070,7 @@ static void NetPlayer_SetLocation(struct Entity* e, struct LocationUpdate* updat
static void NetPlayer_Tick(struct Entity* e, double delta) {
struct NetPlayer* p = (struct NetPlayer*)e;
Player_CheckSkin(&p->Base);
Player_CheckSkin((struct Player*)p);
NetInterpComp_AdvanceState(&p->Interp);
AnimatedComp_Update(e, p->Interp.Prev.Pos, p->Interp.Next.Pos, delta);
}
@@ -1093,7 +1093,7 @@ static void NetPlayer_RenderName(struct Entity* e) {
distance = Model_RenderDistance(e);
threshold = Entities_NameMode == NAME_MODE_ALL_UNSCALED ? 8192 * 8192 : 32 * 32;
if (distance <= (float)threshold) Player_DrawName(&p->Base);
if (distance <= (float)threshold) Player_DrawName((struct Player*)p);
}
struct EntityVTABLE netPlayer_VTABLE = {
@@ -1103,6 +1103,6 @@ struct EntityVTABLE netPlayer_VTABLE = {
void NetPlayer_Init(struct NetPlayer* p, const String* displayName, const String* skinName) {
Mem_Set(p, 0, sizeof(struct NetPlayer));
Player_Init(&p->Base);
Player_SetName(&p->Base, displayName, skinName);
Player_SetName((struct Player*)p, displayName, skinName);
p->Base.VTABLE = &netPlayer_VTABLE;
}
@@ -145,11 +145,12 @@ static void ErrorHandler_DumpCommon(String* str, void* ctx) {
}
static void ErrorHandler_DumpRegisters(void* ctx) {
CONTEXT* r;
String str; char strBuffer[STRING_SIZE * 8];
if (!ctx) return;
CONTEXT* r = (CONTEXT*)ctx;
char strBuffer[STRING_SIZE * 8];
String str = String_FromArray(strBuffer);
r = (CONTEXT*)ctx;
String_InitArray(str, strBuffer);
String_AppendConst(&str, "-- registers --\r\n");
#ifdef _M_IX86
@@ -577,11 +578,12 @@ static void X11_MessageBox(const char* title, const char* text, X11Window* w) {
*-------------------------------------------------------Info dumping------------------------------------------------------*
*#########################################################################################################################*/
static void ErrorHandler_DumpRegisters(void* ctx) {
mcontext_t r;
String str; char strBuffer[STRING_SIZE * 8];
if (!ctx) return;
mcontext_t r = ((ucontext_t*)ctx)->uc_mcontext;
char strBuffer[STRING_SIZE * 8];
String str = String_FromArray(strBuffer);
r = ((ucontext_t*)ctx)->uc_mcontext;
String_InitArray(str, strBuffer);
String_AppendConst(&str, "-- registers --\n");
/* TODO: There must be a better way of getting these.. */
@@ -637,11 +639,12 @@ void ErrorHandler_ShowDialog(const char* title, const char* msg) {
#endif
#ifdef CC_BUILD_OSX
static void ErrorHandler_DumpRegisters(void* ctx) {
mcontext_t r;
String str; char strBuffer[STRING_SIZE * 8];
if (!ctx) return;
mcontext_t r = ((ucontext_t*)ctx)->uc_mcontext;
char strBuffer[STRING_SIZE * 8];
String str = String_FromArray(strBuffer);
r = ((ucontext_t*)ctx)->uc_mcontext;
String_InitArray(str, strBuffer);
String_AppendConst(&str, "-- registers --\n");
/* You can find these definitions at /usr/include/mach/i386/_structs.h */
@@ -105,8 +105,9 @@ char game_defTexPackBuffer[STRING_SIZE];
String game_defTexPack = String_FromArray(game_defTexPackBuffer);
void Game_GetDefaultTexturePack(String* texPack) {
char texPathBuffer[STRING_SIZE];
String texPath = String_FromArray(texPathBuffer);
String texPath; char texPathBuffer[STRING_SIZE];
String_InitArray(texPath, texPathBuffer);
String_Format2(&texPath, "texpacks%r%s", &Directory_Separator, &game_defTexPack);
if (File_Exists(&texPath) && !Game_ClassicMode) {
@@ -412,13 +413,10 @@ static void Game_InitScheduledTasks(void) {
void Game_Free(void* obj);
void Game_Load(void) {
char renderTypeBuffer[STRING_SIZE];
String renderType = String_FromArray(renderTypeBuffer);
char titleBuffer[STRING_SIZE];
String title = String_FromArray(titleBuffer);
struct IGameComponent comp;
int i, flags;
String renderType; char renderTypeBuffer[STRING_SIZE];
String title; char titleBuffer[STRING_SIZE];
Game_ViewDistance = 512;
Game_MaxViewDistance = 32768;
@@ -478,6 +476,7 @@ void Game_Load(void) {
ChunkUpdater_Init();
EnvRenderer_MakeComponent(&comp); Game_AddComponent(&comp);
String_InitArray(renderType, renderTypeBuffer);
Options_Get(OPT_RENDER_TYPE, &renderType, "normal");
flags = Game_CalcRenderType(&renderType);
@@ -533,6 +532,7 @@ void Game_Load(void) {
}*/
if (Gfx_WarnIfNecessary()) EnvRenderer_UseLegacyMode(true);
String_InitArray(title, titleBuffer);
String_Format2(&title, "Connecting to %s:%i..", &Game_IPAddress, &Game_Port);
Gui_FreeActive();
@@ -331,18 +331,18 @@ void Hotkeys_Init(void) {
}
void Hotkeys_UserRemovedHotkey(Key trigger, HotkeyFlags flags) {
char keyBuffer[STRING_SIZE];
String key = String_FromArray(keyBuffer);
String key; char keyBuffer[STRING_SIZE];
String_InitArray(key, keyBuffer);
String_Format2(&key, "hotkey-%c&%i", Key_Names[trigger], &flags);
Options_SetString(&key, NULL);
}
void Hotkeys_UserAddedHotkey(Key trigger, HotkeyFlags flags, bool moreInput, const String* text) {
char keyBuffer[STRING_SIZE];
String key = String_FromArray(keyBuffer);
char valueBuffer[STRING_SIZE * 2];
String value = String_FromArray(valueBuffer);
String key; char keyBuffer[STRING_SIZE];
String value; char valueBuffer[STRING_SIZE * 2];
String_InitArray(key, keyBuffer);
String_InitArray(value, valueBuffer);
String_Format2(&key, "hotkey-%c&%i", Key_Names[trigger], &flags);
String_Format2(&value, "%t&%s", &moreInput, text);
@@ -795,26 +795,26 @@ static void EditHotkeyScreen_MakeFlags(int flags, String* str) {
}
static void EditHotkeyScreen_MakeBaseKey(struct EditHotkeyScreen* s, Widget_LeftClick onClick) {
char textBuffer[STRING_SIZE];
String text = String_FromArray(textBuffer);
String text; char textBuffer[STRING_SIZE];
String_InitArray(text, textBuffer);
String_AppendConst(&text, "Key: ");
String_AppendConst(&text, Key_Names[s->CurHotkey.Trigger]);
EditHotkeyScreen_Make(s, 0, 0, -150, &text, onClick);
}
static void EditHotkeyScreen_MakeModifiers(struct EditHotkeyScreen* s, Widget_LeftClick onClick) {
char textBuffer[STRING_SIZE];
String text = String_FromArray(textBuffer);
String text; char textBuffer[STRING_SIZE];
String_InitArray(text, textBuffer);
String_AppendConst(&text, "Modifiers:");
EditHotkeyScreen_MakeFlags(s->CurHotkey.Flags, &text);
EditHotkeyScreen_Make(s, 1, 0, -100, &text, onClick);
}
static void EditHotkeyScreen_MakeLeaveOpen(struct EditHotkeyScreen* s, Widget_LeftClick onClick) {
char textBuffer[STRING_SIZE];
String text = String_FromArray(textBuffer);
String text; char textBuffer[STRING_SIZE];
String_InitArray(text, textBuffer);
String_AppendConst(&text, "Input stays open: ");
String_AppendConst(&text, s->CurHotkey.StaysOpen ? "ON" : "OFF");
@@ -2075,13 +2075,15 @@ static bool MenuOptionsScreen_MouseMove(void* screen, int x, int y) {
}
static void MenuOptionsScreen_Make(struct MenuOptionsScreen* s, int i, int dir, int y, const char* optName, Widget_LeftClick onClick, Button_Get getter, Button_Set setter) {
char titleBuffer[STRING_SIZE];
String title = String_FromArray(titleBuffer);
struct ButtonWidget* btn;
String title; char titleBuffer[STRING_SIZE];
String_InitArray(title, titleBuffer);
String_AppendConst(&title, optName);
String_AppendConst(&title, ": ");
getter(&title);
struct ButtonWidget* btn = &s->Buttons[i];
btn = &s->Buttons[i];
Menu_Button(s, i, btn, 300, &title, &s->TitleFont, onClick,
ANCHOR_CENTRE, ANCHOR_CENTRE, 160 * dir, y);
Oops, something went wrong.

0 comments on commit aeec580

Please sign in to comment.