Skip to content
Permalink
Browse files

more of that

  • Loading branch information...
UnknownShadow200 committed May 16, 2019
1 parent a154f61 commit 4ac9498ec5fc5dba251134752686a2741b9a2063
Showing with 65 additions and 68 deletions.
  1. +7 −7 src/Block.c
  2. +9 −12 src/Block.h
  3. +2 −1 src/Core.h
  4. +5 −5 src/EnvRenderer.c
  5. +2 −2 src/Graphics.c
  6. +9 −8 src/Gui.c
  7. +5 −5 src/Menus.c
  8. +3 −5 src/Options.c
  9. +9 −9 src/Platform.c
  10. +2 −2 src/Platform.h
  11. +4 −4 src/Stream.c
  12. +1 −1 src/TexturePack.c
  13. +7 −7 src/Window.c
@@ -47,7 +47,7 @@ static PackedCol DefaultSet_FogColour(BlockID b) {
return colZero;
}

static DrawType DefaultSet_Draw(BlockID b) {
static uint8_t DefaultSet_Draw(BlockID b) {
if (b == BLOCK_AIR) return DRAW_GAS;
if (b == BLOCK_LEAVES) return DRAW_TRANSPARENT_THICK;

@@ -68,7 +68,7 @@ static bool DefaultSet_BlocksLight(BlockID b) {
|| b == BLOCK_AIR || DefaultSet_Draw(b) == DRAW_SPRITE);
}

static CollideType DefaultSet_Collide(BlockID b) {
static uint8_t DefaultSet_Collide(BlockID b) {
if (b == BLOCK_ICE) return COLLIDE_ICE;
if (b == BLOCK_WATER || b == BLOCK_STILL_WATER) return COLLIDE_LIQUID_WATER;
if (b == BLOCK_LAVA || b == BLOCK_STILL_LAVA) return COLLIDE_LIQUID_LAVA;
@@ -79,7 +79,7 @@ static CollideType DefaultSet_Collide(BlockID b) {
}

/* Returns a backwards compatible collide type of a block. */
static CollideType DefaultSet_MapOldCollide(BlockID b, CollideType collide) {
static uint8_t DefaultSet_MapOldCollide(BlockID b, uint8_t collide) {
if (b == BLOCK_ROPE && collide == COLLIDE_GAS) return COLLIDE_CLIMB_ROPE;
if (b == BLOCK_ICE && collide == COLLIDE_SOLID) return COLLIDE_ICE;

@@ -90,7 +90,7 @@ static CollideType DefaultSet_MapOldCollide(BlockID b, CollideType collide) {
return collide;
}

static SoundType DefaultSet_DigSound(BlockID b) {
static uint8_t DefaultSet_DigSound(BlockID b) {
if (b >= BLOCK_RED && b <= BLOCK_WHITE) return SOUND_CLOTH;
if (b >= BLOCK_LIGHT_PINK && b <= BLOCK_TURQUOISE) return SOUND_CLOTH;
if (b == BLOCK_IRON || b == BLOCK_GOLD) return SOUND_METAL;
@@ -113,7 +113,7 @@ static SoundType DefaultSet_DigSound(BlockID b) {
return SOUND_NONE;
}

static SoundType DefaultSet_StepSound(BlockID b) {
static uint8_t DefaultSet_StepSound(BlockID b) {
if (b == BLOCK_GLASS) return SOUND_STONE;
if (b == BLOCK_ROPE) return SOUND_CLOTH;
if (DefaultSet_Draw(b) == DRAW_SPRITE) return SOUND_NONE;
@@ -177,7 +177,7 @@ static void Block_RecalcIsLiquid(BlockID b) {
(collide == COLLIDE_LIQUID_LAVA && Blocks.Draw[b] == DRAW_TRANSPARENT);
}

void Block_SetCollide(BlockID block, CollideType collide) {
void Block_SetCollide(BlockID block, uint8_t collide) {
/* necessary if servers redefined core blocks, before extended collide types were added */
collide = DefaultSet_MapOldCollide(block, collide);
Blocks.ExtendedCollide[block] = collide;
@@ -192,7 +192,7 @@ void Block_SetCollide(BlockID block, CollideType collide) {
Blocks.Collide[block] = collide;
}

void Block_SetDrawType(BlockID block, DrawType draw) {
void Block_SetDrawType(BlockID block, uint8_t draw) {
Vector3 zero = Vector3_Zero();
Vector3 one = Vector3_One();

@@ -11,25 +11,25 @@
struct IGameComponent;
extern struct IGameComponent Blocks_Component;

typedef enum SoundType_ {
enum SoundType {
SOUND_NONE, SOUND_WOOD, SOUND_GRAVEL, SOUND_GRASS,
SOUND_STONE, SOUND_METAL, SOUND_GLASS, SOUND_CLOTH,
SOUND_SAND, SOUND_SNOW, SOUND_COUNT
} SoundType;
};
extern const char* Sound_Names[SOUND_COUNT];

/* Describes how a block is rendered in the world. */
typedef enum DrawType_ {
enum DrawType {
DRAW_OPAQUE, /* Completely covers blocks behind (e.g. dirt). */
DRAW_TRANSPARENT, /* Blocks behind show (e.g. glass). Pixels either fully visible or invisible. */
DRAW_TRANSPARENT_THICK, /* Same as Transparent, but all neighbour faces show. (e.g. leaves) */
DRAW_TRANSLUCENT, /* Blocks behind show (e.g. water). Pixels blend with other blocks behind. */
DRAW_GAS, /* Does not show (e.g. air). Can still be collided with. */
DRAW_SPRITE /* Block renders as an X (e.g. sapling). Pixels either fully visible or invisible. */
} DrawType;
};

/* Describes the interaction a block has with a player when they collide with it. */
typedef enum CollideType_ {
enum CollideType {
COLLIDE_GAS, /* No interaction when player collides. */
COLLIDE_LIQUID, /* 'swimming'/'bobbing' interaction when player collides. */
COLLIDE_SOLID, /* Block completely stops the player when they are moving. */
@@ -38,7 +38,7 @@ typedef enum CollideType_ {
COLLIDE_LIQUID_WATER, /* Water style 'swimming'/'bobbing' interaction when player collides. */
COLLIDE_LIQUID_LAVA, /* Lava style 'swimming'/'bobbing' interaction when player collides. */
COLLIDE_CLIMB_ROPE /* Rope/Ladder style climbing interaction when player collides. */
} CollideType;
};

CC_VAR extern struct _BlockLists {
/* Whether this block is a liquid. (Like water/lava) */
@@ -110,19 +110,16 @@ if (Blocks.Tinted[block]) {\
col.B = (uint8_t)(col.B * tintCol.B / 255);\
}

#ifdef EXTENDED_BLOCKS
extern void Block_SetUsedCount(int count);
#endif

/* Returns whether the given block has been changed from default. */
bool Block_IsCustomDefined(BlockID block);
/* Sets whether the given block has been changed from default. */
void Block_SetCustomDefined(BlockID block, bool defined);
void Block_DefineCustom(BlockID block);

/* Sets the basic and extended collide types of the given block. */
void Block_SetCollide(BlockID block, CollideType collide);
void Block_SetDrawType(BlockID block, DrawType draw);
void Block_SetCollide(BlockID block, uint8_t collide);
/* Sets draw type and updates related state (e.g. FullOpaque) for the given block. */
void Block_SetDrawType(BlockID block, uint8_t draw);
/* Resets all the properties of the given block to default. */
void Block_ResetProps(BlockID block);

@@ -56,14 +56,15 @@ typedef uint16_t Codepoint;
#ifdef __APPLE__
/* TODO: REMOVE THIS AWFUL AWFUL HACK */
#include <stdbool.h>
#elif __cplusplus
#else
typedef uint8_t bool;
#define true 1
#define false 0
#endif

#ifndef NULL
#ifdef __cplusplus
#if __cplusplus
#define NULL 0
#else
#define NULL ((void*)0)
@@ -194,7 +194,7 @@ static void EnvRenderer_UpdateClouds(void) {

ptr = v;
if (clouds_vertices > ENV_SMALL_VERTICES) {
ptr = Mem_Alloc(clouds_vertices, sizeof(VertexP3fT2fC4b), "temp clouds vertices");
ptr = (VertexP3fT2fC4b*)Mem_Alloc(clouds_vertices, sizeof(VertexP3fT2fC4b), "clouds vertices");
}

EnvRenderer_DrawCloudsY(x1, z1, x2, z2, Env.CloudsHeight, ptr);
@@ -273,7 +273,7 @@ static void EnvRenderer_UpdateSky(void) {

ptr = v;
if (sky_vertices > ENV_SMALL_VERTICES) {
ptr = Mem_Alloc(sky_vertices, sizeof(VertexP3fC4b), "temp sky vertices");
ptr = (VertexP3fC4b*)Mem_Alloc(sky_vertices, sizeof(VertexP3fC4b), "sky vertices");
}

height = max((World.Height + 2), Env.CloudsHeight) + 6;
@@ -368,7 +368,7 @@ static Vector3I weather_lastPos;

static void EnvRenderer_InitWeatherHeightmap(void) {
int i;
Weather_Heightmap = Mem_Alloc(World.Width * World.Length, 2, "weather heightmap");
Weather_Heightmap = (int16_t*)Mem_Alloc(World.Width * World.Length, 2, "weather heightmap");

for (i = 0; i < World.Width * World.Length; i++) {
Weather_Heightmap[i] = Int16_MaxValue;
@@ -714,7 +714,7 @@ static void EnvRenderer_UpdateMapSides(void) {

ptr = v;
if (sides_vertices > ENV_SMALL_VERTICES) {
ptr = Mem_Alloc(sides_vertices, sizeof(VertexP3fT2fC4b), "temp sides vertices");
ptr = (VertexP3fT2fC4b*)Mem_Alloc(sides_vertices, sizeof(VertexP3fT2fC4b), "sides vertices");
}
cur = ptr;

@@ -768,7 +768,7 @@ static void EnvRenderer_UpdateMapEdges(void) {

ptr = v;
if (edges_vertices > ENV_SMALL_VERTICES) {
ptr = Mem_Alloc(edges_vertices, sizeof(VertexP3fT2fC4b), "temp edge vertices");
ptr = (VertexP3fT2fC4b*)Mem_Alloc(edges_vertices, sizeof(VertexP3fT2fC4b), "edge vertices");
}
cur = ptr;

@@ -373,7 +373,7 @@ static void D3D9_RecreateDevice(void) {

void Gfx_Init(void) {
Gfx.MinZNear = 0.05f;
void* winHandle = Window_GetHandle();
HWND winHandle = (HWND)Window_GetHandle();
d3d = Direct3DCreate9(D3D_SDK_VERSION);

D3D9_FindCompatibleFormat();
@@ -465,7 +465,7 @@ static void D3D9_DoMipmaps(IDirect3DTexture9* texture, int x, int y, Bitmap* bmp
if (width > 1) width /= 2;
if (height > 1) height /= 2;

cur = Mem_Alloc(width * height, 4, "mipmaps");
cur = (uint8_t*)Mem_Alloc(width * height, 4, "mipmaps");
Gfx_GenMipmaps(width, height, cur, prev);

Bitmap_Init(mipmap, width, height, cur);
@@ -24,40 +24,41 @@ struct Screen* Gui_Overlays[GUI_MAX_OVERLAYS];
int Gui_OverlaysCount;

void Gui_DefaultRecreate(void* elem) {
struct GuiElem* e = elem;
struct GuiElem* e = (struct GuiElem*)elem;
Elem_Free(e); Elem_Init(e);
}

void Screen_CommonInit(void* screen) {
struct Screen* s = screen;
struct Screen* s = (struct Screen*)screen;
Event_RegisterVoid(&GfxEvents.ContextLost, s, s->VTABLE->ContextLost);
Event_RegisterVoid(&GfxEvents.ContextRecreated, s, s->VTABLE->ContextRecreated);

if (Gfx.LostContext) return;
s->VTABLE->ContextRecreated(s);
}

void Screen_CommonFree(void* screen) { struct Screen* s = screen;
void Screen_CommonFree(void* screen) {
struct Screen* s = (struct Screen*)screen;
Event_UnregisterVoid(&GfxEvents.ContextLost, s, s->VTABLE->ContextLost);
Event_UnregisterVoid(&GfxEvents.ContextRecreated, s, s->VTABLE->ContextRecreated);
s->VTABLE->ContextLost(s);
}

void Widget_SetLocation(void* widget, uint8_t horAnchor, uint8_t verAnchor, int xOffset, int yOffset) {
struct Widget* w = widget;
struct Widget* w = (struct Widget*)widget;
w->HorAnchor = horAnchor; w->VerAnchor = verAnchor;
w->XOffset = xOffset; w->YOffset = yOffset;
Widget_Reposition(w);
}

void Widget_CalcPosition(void* widget) {
struct Widget* w = widget;
struct Widget* w = (struct Widget*)widget;
w->X = Gui_CalcPos(w->HorAnchor, w->XOffset, w->Width , Game.Width );
w->Y = Gui_CalcPos(w->VerAnchor, w->YOffset, w->Height, Game.Height);
}

void Widget_Reset(void* widget) {
struct Widget* w = widget;
struct Widget* w = (struct Widget*)widget;
w->Active = false;
w->Disabled = false;
w->X = 0; w->Y = 0;
@@ -69,7 +70,7 @@ void Widget_Reset(void* widget) {
}

bool Widget_Contains(void* widget, int x, int y) {
struct Widget* w = widget;
struct Widget* w = (struct Widget*)widget;
return Gui_Contains(w->X, w->Y, w->Width, w->Height, x, y);
}

@@ -176,7 +177,7 @@ void Gui_FreeActive(void) {
if (Gui_Active) { Elem_TryFree(Gui_Active); }
}
void Gui_Close(void* screen) {
struct Screen* s = screen;
struct Screen* s = (struct Screen*)screen;
if (s) { Elem_TryFree(s); }
if (s == Gui_Active) Gui_SetActive(NULL);
}
@@ -473,8 +473,8 @@ static void ListScreen_QuickSort(int left, int right) {
}
}

static String ListScreen_UNSAFE_GetCur(struct ListScreen* s, struct Widget* w) {
int i = Menu_Index(s, w);
static String ListScreen_UNSAFE_GetCur(struct ListScreen* s, void* widget) {
int i = Menu_Index(s, widget);
return ListScreen_UNSAFE_Get(s, s->CurrentIndex + i);
}

@@ -1046,7 +1046,7 @@ static void GenLevelScreen_InputClick(void* screen, void* input) {
struct GenLevelScreen* s = (struct GenLevelScreen*)screen;
if (s->Selected) s->Selected->Base.ShowCaret = false;

s->Selected = input;
s->Selected = (struct MenuInputWidget*)input;
Elem_HandlesMouseDown(&s->Selected->Base, Mouse_X, Mouse_Y, MOUSE_LEFT);
s->Selected->Base.ShowCaret = true;
}
@@ -1263,7 +1263,7 @@ static void SaveLevelScreen_Save(void* screen, void* widget, const char* ext) {
String path; char pathBuffer[FILENAME_SIZE];

struct SaveLevelScreen* s = (struct SaveLevelScreen*)screen;
struct ButtonWidget* btn = widget;
struct ButtonWidget* btn = (struct ButtonWidget*)widget;
String file = s->Input.Base.Text;

if (!file.length) {
@@ -2917,7 +2917,7 @@ static void WarningOverlay_MakeButtons(void* menu, struct ButtonWidget* btns, bo
const static String alwaysYes = String_FromConst("Always yes");
const static String alwaysNo = String_FromConst("Always no");

struct MenuScreen* s = menu;
struct MenuScreen* s = (struct MenuScreen*)menu;
Menu_Button(s, 4, &btns[0], 160, &yes, &s->TitleFont, yesClick,
ANCHOR_CENTRE, ANCHOR_CENTRE, -110, 30);
Menu_Button(s, 5, &btns[1], 160, &no, &s->TitleFont, noClick,
@@ -175,7 +175,7 @@ void Options_SetSecure(const char* opt, const String* src, const String* key) {
if (Platform_Encrypt(src->buffer, src->length, &enc, &encLen)) {
/* fallback to NOT SECURE XOR. Prevents simple reading from options.txt */
encLen = src->length;
enc = Mem_Alloc(encLen, 1, "XOR encode");
enc = (uint8_t*)Mem_Alloc(encLen, 1, "XOR encode");

for (i = 0; i < encLen; i++) {
enc[i] = (uint8_t)(src->buffer[i] ^ key->buffer[i % key->length] ^ 0x43);
@@ -205,15 +205,13 @@ void Options_GetSecure(const char* opt, String* dst, const String* key) {
if (Platform_Decrypt(data, dataLen, &dec, &decLen)) {
/* fallback to NOT SECURE XOR. Prevents simple reading from options.txt */
decLen = dataLen;
dec = Mem_Alloc(decLen, 1, "XOR decode");
dec = (uint8_t*)Mem_Alloc(decLen, 1, "XOR decode");

for (i = 0; i < decLen; i++) {
dec[i] = (uint8_t)(data[i] ^ key->buffer[i % key->length] ^ 0x43);
}
}

for (i = 0; i < decLen; i++) {
String_Append(dst, dec[i]);
}
for (i = 0; i < decLen; i++) String_Append(dst, dec[i]);
Mem_Free(dec);
}
Oops, something went wrong.

0 comments on commit 4ac9498

Please sign in to comment.
You can’t perform that action at this time.