Reduce web client js by 80 kb

This commit is contained in:
UnknownShadow200 2019-05-26 22:12:38 +10:00
parent cb3505c2b9
commit 3101d918c9
4 changed files with 20 additions and 22 deletions

View File

@ -12,6 +12,18 @@
#include "Chat.h" #include "Chat.h"
#include "Stream.h" #include "Stream.h"
int Audio_SoundsVolume, Audio_MusicVolume;
#ifdef CC_BUILD_WEB
/* Can't use mojang's sounds or music assets, so just stub everything out */
static void Audio_Init(void) { }
static void Audio_Free(void) { }
void Audio_SetMusic(int volume) { }
void Audio_SetSounds(int volume) { }
void Audio_PlayDigSound(uint8_t type) { }
void Audio_PlayStepSound(uint8_t type) { }
#else
#if defined CC_BUILD_WINMM #if defined CC_BUILD_WINMM
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#define NOSERVICE #define NOSERVICE
@ -34,8 +46,6 @@
#include <AL/alc.h> #include <AL/alc.h>
#endif #endif
#endif #endif
int Audio_SoundsVolume, Audio_MusicVolume;
static StringsBuffer files; static StringsBuffer files;
static void Volume_Mix16(int16_t* samples, int count, int volume) { static void Volume_Mix16(int16_t* samples, int count, int volume) {
@ -382,20 +392,6 @@ ReturnCode Audio_IsFinished(AudioHandle handle, bool* finished) {
alGetSourcei(ctx->Source, AL_SOURCE_STATE, &state); alGetSourcei(ctx->Source, AL_SOURCE_STATE, &state);
*finished = state != AL_PLAYING; return 0; *finished = state != AL_PLAYING; return 0;
} }
#else
struct AudioContext { int Count; struct AudioFormat Format; };
static struct AudioContext Audio_Contexts[1];
void Audio_Open(AudioHandle* handle, int buffers) { }
ReturnCode Audio_Close(AudioHandle handle) { return 1; }
ReturnCode Audio_SetFormat(AudioHandle handle, struct AudioFormat* format) { return 1; }
ReturnCode Audio_BufferData(AudioHandle handle, int idx, void* data, uint32_t dataSize) { return 1; }
ReturnCode Audio_Play(AudioHandle handle) { return 1; }
ReturnCode Audio_Stop(AudioHandle handle) { return 1; }
ReturnCode Audio_IsCompleted(AudioHandle handle, int idx, bool* completed) { return 1; }
ReturnCode Audio_IsFinished(AudioHandle handle, bool* finished) { return 1; }
void Audio_SysInit(void) { }
void Audio_SysFree(void) { }
#endif #endif
static ReturnCode Audio_AllCompleted(AudioHandle handle, bool* finished) { static ReturnCode Audio_AllCompleted(AudioHandle handle, bool* finished) {
@ -940,6 +936,7 @@ static void Audio_Free(void) {
Audio_SysFree(); Audio_SysFree();
Event_UnregisterBlock(&UserEvents.BlockChanged, NULL, Audio_PlayBlockSound); Event_UnregisterBlock(&UserEvents.BlockChanged, NULL, Audio_PlayBlockSound);
} }
#endif
struct IGameComponent Audio_Component = { struct IGameComponent Audio_Component = {
Audio_Init, /* Init */ Audio_Init, /* Init */

View File

@ -566,7 +566,7 @@ bool Launcher_StartGame(const String* user, const String* mppass, const String*
"echo Copying updated version\r\n" \ "echo Copying updated version\r\n" \
"move ClassiCube.update \"%s\"\r\n" \ "move ClassiCube.update \"%s\"\r\n" \
"echo Starting launcher again\r\n" \ "echo Starting launcher again\r\n" \
"start %s\r\n" \ "start \"%s\"\r\n" \
"exit\r\n" "exit\r\n"
#else #else
#define UPDATE_SCRIPT \ #define UPDATE_SCRIPT \
@ -586,7 +586,7 @@ bool Launcher_StartGame(const String* user, const String* mppass, const String*
"echo Copying updated version\n" \ "echo Copying updated version\n" \
"mv ./ClassiCube.update \"./%s\"\n" \ "mv ./ClassiCube.update \"./%s\"\n" \
"echo Starting launcher again\n" \ "echo Starting launcher again\n" \
"./%s\n" "\"./%s\"\n"
#endif #endif
/* The weird 'cd' line changes current directory to the directory update.sh is in */ /* The weird 'cd' line changes current directory to the directory update.sh is in */
/* Needed because bash's current directory isn't always client's directory (e.g. on OSX) */ /* Needed because bash's current directory isn't always client's directory (e.g. on OSX) */

View File

@ -634,9 +634,9 @@ static void GeneratingScreen_Init(void* screen) {
Event_RaiseVoid(&WorldEvents.NewMap); Event_RaiseVoid(&WorldEvents.NewMap);
if (Gen_Vanilla) { if (Gen_Vanilla) {
Thread_Start(&NotchyGen_Generate, true); Thread_Start(NotchyGen_Generate, true);
} else { } else {
Thread_Start(&FlatgrassGen_Generate, true); Thread_Start(FlatgrassGen_Generate, true);
} }
} }

View File

@ -485,6 +485,7 @@ ReturnCode Stream_ReadLine(struct Stream* s, String* text) {
ReturnCode Stream_WriteLine(struct Stream* s, String* text) { ReturnCode Stream_WriteLine(struct Stream* s, String* text) {
uint8_t buffer[2048 + 10]; /* some space for newline */ uint8_t buffer[2048 + 10]; /* some space for newline */
const char* nl;
uint8_t* cur; uint8_t* cur;
Codepoint cp; Codepoint cp;
ReturnCode res; ReturnCode res;
@ -502,7 +503,7 @@ ReturnCode Stream_WriteLine(struct Stream* s, String* text) {
len += Convert_UnicodeToUtf8(cp, cur); len += Convert_UnicodeToUtf8(cp, cur);
} }
cur = _NL; nl = _NL;
while (*cur) { buffer[len++] = *cur++; } while (*nl) { buffer[len++] = *nl++; }
return Stream_Write(s, buffer, len); return Stream_Write(s, buffer, len);
} }