Permalink
Browse files

move Block_RecalculateAllSpriteBB out of TexturePack.c

  • Loading branch information...
UnknownShadow200 committed Nov 30, 2018
1 parent 3ae356b commit da93962ec634fc71fffcf64d0ae8526a12334c93
@@ -129,11 +129,7 @@ public sealed class ModelCommand : Command {
}

public override void Execute(string[] args) {
if (args.Length == 1) {
game.Chat.Add("&e/client model: &cYou didn't specify a model name.");
} else {
game.LocalPlayer.SetModel(args[1]);
}
foreach (IGameComponent comp in game.Components) { comp.Dispose(); }
}
}

@@ -56,7 +56,7 @@ public sealed partial class LauncherWindow {

Font logoFont;
PlatformDrawer platformDrawer;
public void Init() {
void Init() {
Window.Resize += Resize;
Window.FocusedChanged += RedrawAll;
Window.WindowStateChanged += Resize;
@@ -247,7 +247,7 @@ public sealed partial class LauncherWindow {
if (IsShutdown(key)) ShouldExit = true;
}

public void Dispose() {
void Dispose() {
Window.Resize -= Resize;
Window.FocusedChanged -= RedrawAll;
Window.WindowStateChanged -= Resize;
@@ -40,7 +40,7 @@ public static class Client {
static bool StartImpl(ClientStartData data, bool ccSkins, string args, ref bool shouldExit) {
if (!Platform.FileExists(GetExeName())) return false;

CheckSettings(data, ccSkins, out shouldExit);
UpdateSettings(data, ccSkins, out shouldExit);
try {
StartProcess(args);
} catch (Win32Exception ex) {
@@ -97,7 +97,7 @@ public static class Client {
}
}

internal static void CheckSettings(ClientStartData data, bool ccSkins, out bool shouldExit) {
static void UpdateSettings(ClientStartData data, bool ccSkins, out bool shouldExit) {
shouldExit = false;
// Make sure if the client has changed some settings in the meantime, we keep the changes
if (!Options.Load())
@@ -682,13 +682,15 @@ static void Blocks_Reset(void) {
Block_RecalculateAllSpriteBB();
}

static void Blocks_AtlasChanged(void* obj) { Block_RecalculateAllSpriteBB(); }
static void Blocks_Init(void) {
int block;
for (block = BLOCK_AIR; block <= BLOCK_MAX_DEFINED; block++) {
Block_CanPlace[block] = true;
Block_CanDelete[block] = true;
}
Blocks_Reset();
Event_RegisterVoid(&TextureEvents_AtlasChanged, NULL, Blocks_AtlasChanged);

Block_CanPlace[BLOCK_AIR] = false; Block_CanDelete[BLOCK_AIR] = false;
Block_CanPlace[BLOCK_LAVA] = false; Block_CanDelete[BLOCK_LAVA] = false;
@@ -698,8 +700,12 @@ static void Blocks_Init(void) {
Block_CanPlace[BLOCK_BEDROCK] = false; Block_CanDelete[BLOCK_BEDROCK] = false;
}

static void Blocks_Free(void) {
Event_UnregisterVoid(&TextureEvents_AtlasChanged, NULL, Blocks_AtlasChanged);
}

struct IGameComponent Blocks_Component = {
Blocks_Init, /* Init */
NULL, /* Free */
Blocks_Free, /* Free */
Blocks_Reset, /* Reset */
};
@@ -209,6 +209,7 @@
<ClInclude Include="Deflate.h" />
<ClInclude Include="Gui.h" />
<ClInclude Include="HeldBlockRenderer.h" />
<ClInclude Include="Launcher.h" />
<ClInclude Include="Model.h" />
<ClInclude Include="Input.h" />
<ClInclude Include="InputHandler.h" />
@@ -118,6 +118,9 @@
<Filter Include="Source Files\Freetype">
<UniqueIdentifier>{bff86df8-7005-42a8-80c1-5468c1196336}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\Launcher">
<UniqueIdentifier>{6b1102a4-29d5-4c01-8f32-b9d9cb19b8aa}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Platform.h">
@@ -297,6 +300,9 @@
<ClInclude Include="Graphics.h">
<Filter>Header Files\Graphics</Filter>
</ClInclude>
<ClInclude Include="Launcher.h">
<Filter>Header Files\Launcher</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="String.c">
@@ -33,7 +33,7 @@ GfxResourceID Gfx_defaultIb;
GfxResourceID Gfx_quadVb, Gfx_texVb;
ScheduledTaskCallback Gfx_LostContextFunction;

static int Gfx_strideSizes[2] = { 16, 24 };
static int gfx_strideSizes[2] = { 16, 24 };
static int gfx_batchStride, gfx_batchFormat = -1;

static bool gfx_vsync, gfx_fogEnabled;
@@ -703,7 +703,7 @@ static void D3D9_RestoreRenderStates(void) {
*---------------------------------------------------Vertex/Index buffers--------------------------------------------------*
*#########################################################################################################################*/
GfxResourceID Gfx_CreateDynamicVb(VertexFormat fmt, int maxVertices) {
int size = maxVertices * Gfx_strideSizes[fmt];
int size = maxVertices * gfx_strideSizes[fmt];
IDirect3DVertexBuffer9* vbuffer;
ReturnCode res = IDirect3DDevice9_CreateVertexBuffer(device, size, D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY,
d3d9_formatMappings[fmt], D3DPOOL_DEFAULT, &vbuffer, NULL);
@@ -723,7 +723,7 @@ static void D3D9_SetVbData(IDirect3DVertexBuffer9* buffer, void* data, int size,
}

GfxResourceID Gfx_CreateVb(void* vertices, VertexFormat fmt, int count) {
int size = count * Gfx_strideSizes[fmt];
int size = count * gfx_strideSizes[fmt];
IDirect3DVertexBuffer9* vbuffer;
ReturnCode res;

@@ -781,7 +781,7 @@ void Gfx_SetVertexFormat(VertexFormat fmt) {

ReturnCode res = IDirect3DDevice9_SetFVF(device, d3d9_formatMappings[fmt]);
if (res) ErrorHandler_Fail2(res, "D3D9_SetBatchFormat");
gfx_batchStride = Gfx_strideSizes[fmt];
gfx_batchStride = gfx_strideSizes[fmt];
}

void Gfx_SetDynamicVbData(GfxResourceID vb, void* vertices, int vCount) {
@@ -1244,14 +1244,14 @@ static GfxResourceID GL_GenAndBind(GLenum target) {

GfxResourceID Gfx_CreateDynamicVb(VertexFormat fmt, int maxVertices) {
GfxResourceID id = GL_GenAndBind(GL_ARRAY_BUFFER);
uint32_t size = maxVertices * Gfx_strideSizes[fmt];
uint32_t size = maxVertices * gfx_strideSizes[fmt];
glBufferData(GL_ARRAY_BUFFER, size, NULL, GL_DYNAMIC_DRAW);
return id;
}

GfxResourceID Gfx_CreateVb(void* vertices, VertexFormat fmt, int count) {
GfxResourceID id = GL_GenAndBind(GL_ARRAY_BUFFER);
uint32_t size = count * Gfx_strideSizes[fmt];
uint32_t size = count * gfx_strideSizes[fmt];
glBufferData(GL_ARRAY_BUFFER, size, vertices, GL_STATIC_DRAW);
return id;
}
@@ -1290,7 +1290,7 @@ GfxResourceID Gfx_CreateVb(void* vertices, VertexFormat fmt, int count) {

uint16_t indices[GFX_MAX_INDICES];
Gfx_MakeIndices(indices, ICOUNT(count));
stride = Gfx_strideSizes[fmt];
stride = gfx_strideSizes[fmt];

glVertexPointer(3, GL_FLOAT, stride, vertices);
glColorPointer(4, GL_UNSIGNED_BYTE, stride, (void*)((uint8_t*)vertices + 12));
@@ -1347,7 +1347,7 @@ void Gfx_SetVertexFormat(VertexFormat fmt) {
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
gfx_batchFormat = fmt;
gfx_batchStride = Gfx_strideSizes[fmt];
gfx_batchStride = gfx_strideSizes[fmt];

if (fmt == VERTEX_FORMAT_P3FT2FC4B) {
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
@@ -0,0 +1,56 @@
#ifndef CC_LAUNCHER_H
#define CC_LAUNCHER_H
#include "Bitmap.h"
#include "String.h"

struct LScreen;
TimeMS Launcher_PatchTime;

extern BitmapCol Launcher_BackgroundCol = BITMAPCOL_CONST(153, 127, 172, 255);
extern BitmapCol Launcher_ButtonBorderCol = BITMAPCOL_CONST( 97, 81, 110, 255);
extern BitmapCol Launcher_ButtonForeActiveCol = BITMAPCOL_CONST(189, 168, 206, 255);
extern BitmapCol Launcher_ButtonForeCol = BITMAPCOL_CONST(141, 114, 165, 255);
extern BitmapCol Launcher_ButtonHighlightCol = BITMAPCOL_CONST(162, 131, 186, 255);

void Launcher_ResetSkin(void);
void Launcher_LoadSkin(void);
void Launcher_SaveSkin(void);

void Launcher_UpdateAsync(void);

extern bool Launcher_ClassicBackground;

void Launcher_TryLoadTexturePack(void);
void Launcher_RedrawBackground(void);

/* Redraws the specified region with the background pixels. */
void Launcher_ResetArea(int x, int y, int width, int height);

extern struct LSCreen* Launcher_Screen;
/* Whether the client drawing area needs to be redrawn/presented to the screen. */
extern bool Launcher_Dirty, Launcher_PendingRedraw;
/* The specific area/region of the window that needs to be redrawn. */
extern Rect2D Launcher_DirtyArea;
String Username;
extern int Launcher_Width, Launcher_Height;
extern Bitmap Launcher_Framebuffer;

/* Whether at the next tick, the launcher window should proceed to stop displaying frames and subsequently exit. */
extern bool Launcher_ShouldExit;
/* Whether update script should be asynchronously run on exit. */
extern bool Launcher_ShouldUpdate;

struct ServerListEntry {
String Hash, Name, Players, MaxPlayers, Flag;
String Uptime, IPAddress, Port, Mppass, Software;
bool Featured;
};
extern struct ServerListEntry* Launcher_Servers;

extern String Launcher_FontName;
void Launcher_SetScreen(struct LScreen* screen);
bool Launcher_ConnectToServer(const String* hash);
void Launcher_Run();

bool Launcher_StartGame(const String* user, const String* mppass, const String* ip, const String* port, const String* server);
#endif
@@ -38,9 +38,9 @@ struct ChunkPartInfo {
struct ChunkInfo {
uint16_t CentreX, CentreY, CentreZ; /* Centre coordinates of the chunk */

uint8_t Visible : 1; /* Whether chunk is visibile to the player */
uint8_t Visible : 1; /* Whether chunk is visible to the player */
uint8_t Empty : 1; /* Whether the chunk is empty of data */
uint8_t PendingDelete : 1; /* Whether chunk is pending deletion*/
uint8_t PendingDelete : 1; /* Whether chunk is pending deletion */
uint8_t AllAir : 1; /* Whether chunk is completely air */
uint8_t : 0; /* pad to next byte*/

@@ -14,7 +14,6 @@
#include "Errors.h"
#include "Chat.h"
#include "ExtMath.h"
#include "Block.h" /* NOTE: Just for block_recalculateallspritebb */
#include "Chat.h"
#include "Options.h"

@@ -313,7 +312,6 @@ static void Animations_Validate(void) {
}
}


static void Animations_Tick(struct ScheduledTask* task) {
int i, size;

@@ -340,6 +338,10 @@ static void Animations_Tick(struct ScheduledTask* task) {
}
}


/*########################################################################################################################*
*--------------------------------------------------Animations component---------------------------------------------------*
*#########################################################################################################################*/
static void Animations_PackChanged(void* obj) {
Animations_Clear();
anims_useLavaAnim = Animations_IsDefaultZip();
@@ -364,10 +366,6 @@ static void Animations_FileChanged(void* obj, struct Stream* stream, const Strin
}
}


/*########################################################################################################################*
*--------------------------------------------------Animations component---------------------------------------------------*
*#########################################################################################################################*/
static void Animations_Init(void) {
ScheduledTask_Add(GAME_DEF_TICKS, Animations_Tick);
Event_RegisterVoid(&TextureEvents_PackChanged, NULL, Animations_PackChanged);
@@ -454,7 +452,6 @@ void Atlas_Update(Bitmap* bmp) {
Atlas_RowsCount = bmp->Height / Atlas_TileSize;
Atlas_RowsCount = min(Atlas_RowsCount, ATLAS2D_MAX_ROWS_COUNT);

Block_RecalculateAllSpriteBB();
Atlas_Update1D();
Atlas_Convert2DTo1D();
}

0 comments on commit da93962

Please sign in to comment.