Permalink
Browse files

attempt to fix again, make lots of variables static to reduce size of…

… linux executable
  • Loading branch information...
UnknownShadow200 committed Nov 9, 2018
1 parent 6453b06 commit caddf623b746eba4d9453685028bbf4cbb4646d8
View
@@ -17,11 +17,11 @@
/*########################################################################################################################*
*-----------------------------------------------------Lava animation------------------------------------------------------*
*#########################################################################################################################*/
float L_soupHeat[LIQUID_ANIM_MAX * LIQUID_ANIM_MAX];
float L_potHeat[LIQUID_ANIM_MAX * LIQUID_ANIM_MAX];
float L_flameHeat[LIQUID_ANIM_MAX * LIQUID_ANIM_MAX];
RNGState L_rnd;
bool L_rndInitalised;
static float L_soupHeat[LIQUID_ANIM_MAX * LIQUID_ANIM_MAX];
static float L_potHeat[LIQUID_ANIM_MAX * LIQUID_ANIM_MAX];
static float L_flameHeat[LIQUID_ANIM_MAX * LIQUID_ANIM_MAX];
static RNGState L_rnd;
static bool L_rndInitalised;
static void LavaAnimation_Tick(uint32_t* ptr, int size) {
int mask = size - 1, shift = Math_Log2(size);
@@ -88,11 +88,11 @@ static void LavaAnimation_Tick(uint32_t* ptr, int size) {
/*########################################################################################################################*
*----------------------------------------------------Water animation------------------------------------------------------*
*#########################################################################################################################*/
float W_soupHeat[LIQUID_ANIM_MAX * LIQUID_ANIM_MAX];
float W_potHeat[LIQUID_ANIM_MAX * LIQUID_ANIM_MAX];
float W_flameHeat[LIQUID_ANIM_MAX * LIQUID_ANIM_MAX];
RNGState W_rnd;
bool W_rndInitalised;
static float W_soupHeat[LIQUID_ANIM_MAX * LIQUID_ANIM_MAX];
static float W_potHeat[LIQUID_ANIM_MAX * LIQUID_ANIM_MAX];
static float W_flameHeat[LIQUID_ANIM_MAX * LIQUID_ANIM_MAX];
static RNGState W_rnd;
static bool W_rndInitalised;
static void WaterAnimation_Tick(uint32_t* ptr, int size) {
int mask = size - 1, shift = Math_Log2(size);
@@ -149,10 +149,10 @@ struct AnimationData {
int16_t Tick, TickDelay;
};
Bitmap anims_bmp;
struct AnimationData anims_list[ATLAS1D_MAX_ATLASES];
int anims_count;
bool anims_validated, anims_useLavaAnim, anims_useWaterAnim;
static Bitmap anims_bmp;
static struct AnimationData anims_list[ATLAS1D_MAX_ATLASES];
static int anims_count;
static bool anims_validated, anims_useLavaAnim, anims_useWaterAnim;
#define ANIM_MIN_ARGS 7
static void Animations_ReadDescription(struct Stream* stream, const String* path) {
View
@@ -62,21 +62,21 @@ static void AsyncRequestList_Free(struct AsyncRequestList* list) {
AsyncRequestList_Init(list);
}
void* async_waitable;
void* async_workerThread;
void* async_pendingMutex;
void* async_processedMutex;
void* async_curRequestMutex;
volatile bool async_terminate;
struct AsyncRequestList async_pending;
struct AsyncRequestList async_processed;
String async_skinServer = String_FromConst("http://static.classicube.net/skins/");
struct AsyncRequest async_curRequest;
volatile int async_curProgress = ASYNC_PROGRESS_NOTHING;
static void* async_waitable;
static void* async_workerThread;
static void* async_pendingMutex;
static void* async_processedMutex;
static void* async_curRequestMutex;
static volatile bool async_terminate;
static struct AsyncRequestList async_pending;
static struct AsyncRequestList async_processed;
static String async_skinServer = String_FromConst("http://static.classicube.net/skins/");
static struct AsyncRequest async_curRequest;
static volatile int async_curProgress = ASYNC_PROGRESS_NOTHING;
/* TODO: Implement these */
bool ManageCookies;
bool KeepAlive;
static bool ManageCookies;
static bool KeepAlive;
/* TODO: Connection pooling */
static void AsyncDownloader_Add(const String* url, bool priority, const String* id, uint8_t type, TimeMS* lastModified, const String* etag, const String* data) {
View
@@ -12,7 +12,7 @@
#include "Chat.h"
#include "Stream.h"
StringsBuffer files;
static StringsBuffer files;
static void Volume_Mix16(int16_t* samples, int count, int volume) {
int i;
@@ -199,9 +199,9 @@ struct SoundOutput { AudioHandle Handle; void* Buffer; uint32_t BufferSize; };
#define HANDLE_INV -1
#define SOUND_INV { HANDLE_INV, NULL, 0 }
struct Soundboard digBoard, stepBoard;
struct SoundOutput monoOutputs[AUDIO_MAX_HANDLES] = { SOUND_INV, SOUND_INV, SOUND_INV, SOUND_INV, SOUND_INV, SOUND_INV };
struct SoundOutput stereoOutputs[AUDIO_MAX_HANDLES] = { SOUND_INV, SOUND_INV, SOUND_INV, SOUND_INV, SOUND_INV, SOUND_INV };
static struct Soundboard digBoard, stepBoard;
static struct SoundOutput monoOutputs[AUDIO_MAX_HANDLES] = { SOUND_INV, SOUND_INV, SOUND_INV, SOUND_INV, SOUND_INV, SOUND_INV };
static struct SoundOutput stereoOutputs[AUDIO_MAX_HANDLES] = { SOUND_INV, SOUND_INV, SOUND_INV, SOUND_INV, SOUND_INV, SOUND_INV };
NOINLINE_ static void Sounds_Fail(ReturnCode res) {
Chat_LogError(res, "playing sounds");
@@ -343,11 +343,11 @@ void Audio_PlayStepSound(uint8_t type) { Sounds_Play(type, &stepBoard); }
/*########################################################################################################################*
*--------------------------------------------------------Music------------------------------------------------------------*
*#########################################################################################################################*/
AudioHandle music_out;
StringsBuffer music_files;
void* music_thread;
void* music_waitable;
volatile bool music_pendingStop, music_joining;
static AudioHandle music_out;
static StringsBuffer music_files;
static void* music_thread;
static void* music_waitable;
static volatile bool music_pendingStop, music_joining;
static ReturnCode Music_Buffer(int i, int16_t* data, int maxSamples, struct VorbisState* ctx) {
int samples = 0;
View
@@ -8,7 +8,7 @@
#include "Event.h"
#include "Entity.h"
GfxResourceID axisLines_vb;
static GfxResourceID axisLines_vb;
#define AXISLINES_NUM_VERTICES 12
#define AXISLINES_THICKNESS (1.0f / 32.0f)
#define AXISLINES_LENGTH 3.0f
View
@@ -55,7 +55,7 @@ enum PngFilter {
};
typedef void (*Png_RowExpander)(int width, uint32_t* palette, uint8_t* src, uint32_t* dst);
uint8_t png_sig[PNG_SIG_SIZE] = { 137, 80, 78, 71, 13, 10, 26, 10 };
static uint8_t png_sig[PNG_SIG_SIZE] = { 137, 80, 78, 71, 13, 10, 26, 10 };
bool Png_Detect(const uint8_t* data, uint32_t len) {
int i;
View
@@ -18,8 +18,8 @@ const char* Sound_Names[SOUND_COUNT] = {
/*########################################################################################################################*
*---------------------------------------------------------Block-----------------------------------------------------------*
*#########################################################################################################################*/
uint32_t Block_DefinedCustomBlocks[BLOCK_COUNT >> 5];
char Block_NamesBuffer[STRING_SIZE * BLOCK_COUNT];
static uint32_t Block_DefinedCustomBlocks[BLOCK_COUNT >> 5];
static char Block_NamesBuffer[STRING_SIZE * BLOCK_COUNT];
#define Block_NamePtr(i) &Block_NamesBuffer[STRING_SIZE * i]
uint8_t Block_TopTex[BLOCK_CPE_COUNT] = { 0, 1, 0, 2, 16, 4, 15, 17, 14, 14,
View
@@ -83,16 +83,16 @@ static uint32_t TickQueue_Dequeue(struct TickQueue* queue) {
}
typedef void(*PhysicsHandler)(int index, BlockID block);
PhysicsHandler Physics_OnActivate[BLOCK_COUNT];
PhysicsHandler Physics_OnRandomTick[BLOCK_COUNT];
PhysicsHandler Physics_OnPlace[BLOCK_COUNT];
PhysicsHandler Physics_OnDelete[BLOCK_COUNT];
typedef void (*PhysicsHandler)(int index, BlockID block);
static PhysicsHandler Physics_OnActivate[BLOCK_COUNT];
static PhysicsHandler Physics_OnRandomTick[BLOCK_COUNT];
static PhysicsHandler Physics_OnPlace[BLOCK_COUNT];
static PhysicsHandler Physics_OnDelete[BLOCK_COUNT];
RNGState physics_rnd;
int physics_tickCount;
int physics_maxWaterX, physics_maxWaterY, physics_maxWaterZ;
struct TickQueue physics_lavaQ, physics_waterQ;
static RNGState physics_rnd;
static int physics_tickCount;
static int physics_maxWaterX, physics_maxWaterY, physics_maxWaterZ;
static struct TickQueue physics_lavaQ, physics_waterQ;
#define PHYSICS_DELAY_MASK 0xF8000000UL
#define PHYSICS_POS_MASK 0x07FFFFFFUL
@@ -472,7 +472,7 @@ static void Physics_HandleCobblestoneSlab(int index, BlockID block) {
}
uint8_t physics_blocksTnt[BLOCK_CPE_COUNT] = {
static uint8_t physics_blocksTnt[BLOCK_CPE_COUNT] = {
0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0,
1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1,
View
@@ -21,24 +21,24 @@
/* Packs an index into the 18x18x18 chunk array. Coordinates range from -1 to 16. */
#define Builder_PackChunk(xx, yy, zz) (((yy) + 1) * EXTCHUNK_SIZE_2 + ((zz) + 1) * EXTCHUNK_SIZE + ((xx) + 1))
BlockID* Builder_Chunk;
uint8_t* Builder_Counts;
int* Builder_BitFlags;
bool Builder_UseBitFlags;
int Builder_X, Builder_Y, Builder_Z;
BlockID Builder_Block;
int Builder_ChunkIndex;
bool Builder_FullBright;
bool Builder_Tinted;
int Builder_ChunkEndX, Builder_ChunkEndZ;
int Builder_Offsets[FACE_COUNT] = { -1,1, -EXTCHUNK_SIZE,EXTCHUNK_SIZE, -EXTCHUNK_SIZE_2,EXTCHUNK_SIZE_2 };
int (*Builder_StretchXLiquid)(int countIndex, int x, int y, int z, int chunkIndex, BlockID block);
int (*Builder_StretchX)(int countIndex, int x, int y, int z, int chunkIndex, BlockID block, Face face);
int (*Builder_StretchZ)(int countIndex, int x, int y, int z, int chunkIndex, BlockID block, Face face);
void (*Builder_RenderBlock)(int countsIndex);
void (*Builder_PreStretchTiles)(int x1, int y1, int z1);
void (*Builder_PostStretchTiles)(int x1, int y1, int z1);
static BlockID* Builder_Chunk;
static uint8_t* Builder_Counts;
static int* Builder_BitFlags;
static bool Builder_UseBitFlags;
static int Builder_X, Builder_Y, Builder_Z;
static BlockID Builder_Block;
static int Builder_ChunkIndex;
static bool Builder_FullBright;
static bool Builder_Tinted;
static int Builder_ChunkEndX, Builder_ChunkEndZ;
static int Builder_Offsets[FACE_COUNT] = { -1,1, -EXTCHUNK_SIZE,EXTCHUNK_SIZE, -EXTCHUNK_SIZE_2,EXTCHUNK_SIZE_2 };
static int (*Builder_StretchXLiquid)(int countIndex, int x, int y, int z, int chunkIndex, BlockID block);
static int (*Builder_StretchX)(int countIndex, int x, int y, int z, int chunkIndex, BlockID block, Face face);
static int (*Builder_StretchZ)(int countIndex, int x, int y, int z, int chunkIndex, BlockID block, Face face);
static void (*Builder_RenderBlock)(int countsIndex);
static void (*Builder_PreStretchTiles)(int x1, int y1, int z1);
static void (*Builder_PostStretchTiles)(int x1, int y1, int z1);
/* Contains state for vertices for a portion of a chunk mesh (vertices that are in a 1D atlas) */
struct Builder1DPart {
@@ -49,9 +49,9 @@ struct Builder1DPart {
/* Part builder data, for both normal and translucent parts.
The first ATLAS1D_MAX_ATLASES parts are for normal parts, remainder are for translucent parts. */
struct Builder1DPart Builder_Parts[ATLAS1D_MAX_ATLASES * 2];
VertexP3fT2fC4b* Builder_Vertices;
int Builder_VerticesElems;
static struct Builder1DPart Builder_Parts[ATLAS1D_MAX_ATLASES * 2];
static VertexP3fT2fC4b* Builder_Vertices;
static int Builder_VerticesElems;
static int Builder1DPart_VerticesCount(struct Builder1DPart* part) {
int i, count = part->sCount;
@@ -410,7 +410,7 @@ static void Builder_DefaultPostStretchTiles(int x1, int y1, int z1) {
}
}
RNGState spriteRng;
static RNGState spriteRng;
static void Builder_DrawSprite(int count) {
TextureLoc texLoc = Block_GetTex(Builder_Block, FACE_XMAX);
int i = Atlas1D_Index(texLoc);
@@ -700,12 +700,12 @@ void NormalBuilder_SetActive(void) {
/*########################################################################################################################*
*-------------------------------------------------Advanced mesh builder---------------------------------------------------*
*#########################################################################################################################*/
Vector3 adv_minBB, adv_maxBB;
bool adv_isTranslucent;
int adv_initBitFlags, adv_lightFlags, adv_baseOffset;
int* adv_bitFlags;
float adv_x1, adv_y1, adv_z1, adv_x2, adv_y2, adv_z2;
PackedCol adv_lerp[5], adv_lerpX[5], adv_lerpZ[5], adv_lerpY[5];
static Vector3 adv_minBB, adv_maxBB;
static bool adv_isTranslucent;
static int adv_initBitFlags, adv_lightFlags, adv_baseOffset;
static int* adv_bitFlags;
static float adv_x1, adv_y1, adv_z1, adv_x2, adv_y2, adv_z2;
static PackedCol adv_lerp[5], adv_lerpX[5], adv_lerpZ[5], adv_lerpY[5];
enum ADV_MASK {
/* z-1 cube points */
@@ -770,7 +770,7 @@ static int Adv_ComputeLightFlags(int x, int y, int z, int cIndex) {
Adv_Lit(x + 1, y, z + 1, cIndex + 1 + 18) << xP1_yM1_zP1;
}
int adv_masks[FACE_COUNT] = {
static int adv_masks[FACE_COUNT] = {
/* XMin face */
(1 << xM1_yM1_zM1) | (1 << xM1_yM1_zCC) | (1 << xM1_yM1_zP1) |
(1 << xM1_yCC_zM1) | (1 << xM1_yCC_zCC) | (1 << xM1_yCC_zP1) |
View
@@ -8,8 +8,8 @@
#include "Entity.h"
#include "Input.h"
Vector2 cam_rotOffset;
bool cam_isForwardThird;
static Vector2 cam_rotOffset;
static bool cam_isForwardThird;
/*########################################################################################################################*
*--------------------------------------------------Perspective camera-----------------------------------------------------*
@@ -35,7 +35,7 @@ static void PerspectiveCamera_GetPickedBlock(struct PickedPos* pos) {
Picking_CalculatePickedBlock(eyePos, dir, reach, pos);
}
Point2D cam_prev, cam_delta;
static Point2D cam_prev, cam_delta;
static void PerspectiveCamera_CentreMousePosition(void) {
Point2D topLeft = Window_PointToScreen(0, 0);
int cenX = topLeft.X + Game_Width / 2;
View
@@ -8,11 +8,11 @@
#include "Platform.h"
#include "ErrorHandler.h"
WindowRef win_handle;
int title_height;
int win_state;
static WindowRef win_handle;
static int title_height;
static int win_state;
/* Hacks for fullscreen */
bool ctx_pendingWindowed, ctx_pendingFullscreen;
static bool ctx_pendingWindowed, ctx_pendingFullscreen;
#define Rect_Width(rect) (rect.right - rect.left)
#define Rect_Height(rect) (rect.bottom - rect.top)
@@ -668,7 +668,7 @@ void Window_SetScreenCursorPos(int x, int y) {
CGAssociateMouseAndMouseCursorPosition(1);
}
bool win_cursorVisible;
static bool win_cursorVisible;
bool Window_GetCursorVisible(void) { return win_cursorVisible; }
void Window_SetCursorVisible(bool visible) {
@@ -684,9 +684,9 @@ void Window_SetCursorVisible(bool visible) {
/*########################################################################################################################*
*-----------------------------------------------------OpenGL context------------------------------------------------------*
*#########################################################################################################################*/
AGLContext ctx_handle;
bool ctx_fullscreen, ctx_firstFullscreen;
Rect2D ctx_windowedBounds;
static AGLContext ctx_handle;
static bool ctx_fullscreen, ctx_firstFullscreen;
static Rect2D ctx_windowedBounds;
static void GLContext_Check(int code, const char* place) {
ReturnCode res;
Oops, something went wrong.

0 comments on commit caddf62

Please sign in to comment.