mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-16 11:06:06 -04:00
Reduce web client js by 80 kb
This commit is contained in:
parent
cb3505c2b9
commit
3101d918c9
29
src/Audio.c
29
src/Audio.c
@ -12,6 +12,18 @@
|
||||
#include "Chat.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
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define NOSERVICE
|
||||
@ -34,8 +46,6 @@
|
||||
#include <AL/alc.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
int Audio_SoundsVolume, Audio_MusicVolume;
|
||||
static StringsBuffer files;
|
||||
|
||||
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);
|
||||
*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
|
||||
|
||||
static ReturnCode Audio_AllCompleted(AudioHandle handle, bool* finished) {
|
||||
@ -940,6 +936,7 @@ static void Audio_Free(void) {
|
||||
Audio_SysFree();
|
||||
Event_UnregisterBlock(&UserEvents.BlockChanged, NULL, Audio_PlayBlockSound);
|
||||
}
|
||||
#endif
|
||||
|
||||
struct IGameComponent Audio_Component = {
|
||||
Audio_Init, /* Init */
|
||||
|
@ -566,7 +566,7 @@ bool Launcher_StartGame(const String* user, const String* mppass, const String*
|
||||
"echo Copying updated version\r\n" \
|
||||
"move ClassiCube.update \"%s\"\r\n" \
|
||||
"echo Starting launcher again\r\n" \
|
||||
"start %s\r\n" \
|
||||
"start \"%s\"\r\n" \
|
||||
"exit\r\n"
|
||||
#else
|
||||
#define UPDATE_SCRIPT \
|
||||
@ -586,7 +586,7 @@ bool Launcher_StartGame(const String* user, const String* mppass, const String*
|
||||
"echo Copying updated version\n" \
|
||||
"mv ./ClassiCube.update \"./%s\"\n" \
|
||||
"echo Starting launcher again\n" \
|
||||
"./%s\n"
|
||||
"\"./%s\"\n"
|
||||
#endif
|
||||
/* 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) */
|
||||
|
@ -634,9 +634,9 @@ static void GeneratingScreen_Init(void* screen) {
|
||||
Event_RaiseVoid(&WorldEvents.NewMap);
|
||||
|
||||
if (Gen_Vanilla) {
|
||||
Thread_Start(&NotchyGen_Generate, true);
|
||||
Thread_Start(NotchyGen_Generate, true);
|
||||
} else {
|
||||
Thread_Start(&FlatgrassGen_Generate, true);
|
||||
Thread_Start(FlatgrassGen_Generate, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -485,6 +485,7 @@ ReturnCode Stream_ReadLine(struct Stream* s, String* text) {
|
||||
|
||||
ReturnCode Stream_WriteLine(struct Stream* s, String* text) {
|
||||
uint8_t buffer[2048 + 10]; /* some space for newline */
|
||||
const char* nl;
|
||||
uint8_t* cur;
|
||||
Codepoint cp;
|
||||
ReturnCode res;
|
||||
@ -502,7 +503,7 @@ ReturnCode Stream_WriteLine(struct Stream* s, String* text) {
|
||||
len += Convert_UnicodeToUtf8(cp, cur);
|
||||
}
|
||||
|
||||
cur = _NL;
|
||||
while (*cur) { buffer[len++] = *cur++; }
|
||||
nl = _NL;
|
||||
while (*nl) { buffer[len++] = *nl++; }
|
||||
return Stream_Write(s, buffer, len);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user