Merge branch 'master' into pr-start
3
.github/workflows/style.yml
vendored
|
@ -23,4 +23,5 @@ jobs:
|
||||||
- name: Check style
|
- name: Check style
|
||||||
run: |
|
run: |
|
||||||
clang-format -version
|
clang-format -version
|
||||||
python3 scripts/fix_style.py --dry-run --base "$(git merge-base origin/master $GITHUB_SHA)"
|
scripts/fix_style.py --dry-run --base origin/master
|
||||||
|
scripts/check_header_guards.py
|
||||||
|
|
4
.gitignore
vendored
|
@ -55,10 +55,6 @@ map_version
|
||||||
mastersrv
|
mastersrv
|
||||||
packetgen
|
packetgen
|
||||||
testrunner
|
testrunner
|
||||||
tileset_borderadd
|
|
||||||
tileset_borderfix
|
|
||||||
tileset_borderrem
|
|
||||||
tileset_borderset
|
|
||||||
twping
|
twping
|
||||||
unicode_confusables
|
unicode_confusables
|
||||||
uuid
|
uuid
|
||||||
|
|
|
@ -2032,10 +2032,6 @@ set_src(TOOLS GLOB src/tools
|
||||||
map_replace_image.cpp
|
map_replace_image.cpp
|
||||||
map_resave.cpp
|
map_resave.cpp
|
||||||
packetgen.cpp
|
packetgen.cpp
|
||||||
tileset_borderadd.cpp
|
|
||||||
tileset_borderfix.cpp
|
|
||||||
tileset_borderrem.cpp
|
|
||||||
tileset_borderset.cpp
|
|
||||||
unicode_confusables.cpp
|
unicode_confusables.cpp
|
||||||
uuid.cpp
|
uuid.cpp
|
||||||
)
|
)
|
||||||
|
|
Before Width: | Height: | Size: 87 KiB After Width: | Height: | Size: 92 KiB |
Before Width: | Height: | Size: 108 KiB After Width: | Height: | Size: 104 KiB |
Before Width: | Height: | Size: 185 KiB After Width: | Height: | Size: 181 KiB |
Before Width: | Height: | Size: 220 KiB After Width: | Height: | Size: 202 KiB |
4
scripts/fix_style.py
Normal file → Executable file
|
@ -1,3 +1,5 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
|
@ -41,6 +43,8 @@ def warn(changed_lines):
|
||||||
result = subprocess.call(["clang-format", "-Werror", "--dry-run"] + ["--lines={}:{}".format(start, end) for start, end in changed_lines[filename]] + [filename]) or result
|
result = subprocess.call(["clang-format", "-Werror", "--dry-run"] + ["--lines={}:{}".format(start, end) for start, end in changed_lines[filename]] + [filename]) or result
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
def get_common_base(base):
|
||||||
|
return subprocess.check_output(["git", "merge-base", "HEAD", base]).decode().strip()
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
import argparse
|
import argparse
|
||||||
|
|
|
@ -2380,11 +2380,60 @@ void CClient::ResetDDNetInfo()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CClient::IsDDNetInfoChanged()
|
||||||
|
{
|
||||||
|
IOHANDLE OldFile = m_pStorage->OpenFile(DDNET_INFO, IOFLAG_READ, IStorage::TYPE_SAVE);
|
||||||
|
|
||||||
|
if(!OldFile)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
IOHANDLE NewFile = m_pStorage->OpenFile(m_aDDNetInfoTmp, IOFLAG_READ, IStorage::TYPE_SAVE);
|
||||||
|
|
||||||
|
if(NewFile)
|
||||||
|
{
|
||||||
|
char aOldData[4096];
|
||||||
|
char aNewData[4096];
|
||||||
|
unsigned OldBytes;
|
||||||
|
unsigned NewBytes;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
OldBytes = io_read(OldFile, aOldData, sizeof(aOldData));
|
||||||
|
NewBytes = io_read(NewFile, aNewData, sizeof(aNewData));
|
||||||
|
|
||||||
|
if(OldBytes != NewBytes || mem_comp(aOldData, aNewData, OldBytes) != 0)
|
||||||
|
{
|
||||||
|
io_close(NewFile);
|
||||||
|
io_close(OldFile);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while(OldBytes > 0);
|
||||||
|
|
||||||
|
io_close(NewFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
io_close(OldFile);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void CClient::FinishDDNetInfo()
|
void CClient::FinishDDNetInfo()
|
||||||
{
|
{
|
||||||
ResetDDNetInfo();
|
ResetDDNetInfo();
|
||||||
m_pStorage->RenameFile(m_aDDNetInfoTmp, DDNET_INFO, IStorage::TYPE_SAVE);
|
if(IsDDNetInfoChanged())
|
||||||
LoadDDNetInfo();
|
{
|
||||||
|
m_pStorage->RenameFile(m_aDDNetInfoTmp, DDNET_INFO, IStorage::TYPE_SAVE);
|
||||||
|
LoadDDNetInfo();
|
||||||
|
|
||||||
|
if(g_Config.m_UiPage == CMenus::PAGE_DDNET)
|
||||||
|
m_ServerBrowser.Refresh(IServerBrowser::TYPE_DDNET);
|
||||||
|
else if(g_Config.m_UiPage == CMenus::PAGE_KOG)
|
||||||
|
m_ServerBrowser.Refresh(IServerBrowser::TYPE_KOG);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_pStorage->RemoveFile(m_aDDNetInfoTmp, IStorage::TYPE_SAVE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef std::tuple<int, int, int> Version;
|
typedef std::tuple<int, int, int> Version;
|
||||||
|
|
|
@ -345,6 +345,7 @@ public:
|
||||||
|
|
||||||
void RequestDDNetInfo();
|
void RequestDDNetInfo();
|
||||||
void ResetDDNetInfo();
|
void ResetDDNetInfo();
|
||||||
|
bool IsDDNetInfoChanged();
|
||||||
void FinishDDNetInfo();
|
void FinishDDNetInfo();
|
||||||
void LoadDDNetInfo();
|
void LoadDDNetInfo();
|
||||||
|
|
||||||
|
|
|
@ -555,6 +555,16 @@ int CGraphics_Threaded::LoadPNG(CImageInfo *pImg, const char *pFilename, int Sto
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CGraphics_Threaded::CopyTextureBufferSub(uint8_t *pDestBuffer, uint8_t *pSourceBuffer, int FullWidth, int FullHeight, int ColorChannelCount, int SubOffsetX, int SubOffsetY, int SubCopyWidth, int SubCopyHeight)
|
||||||
|
{
|
||||||
|
for(int Y = 0; Y < SubCopyHeight; ++Y)
|
||||||
|
{
|
||||||
|
int ImgOffset = ((SubOffsetY + Y) * FullWidth * ColorChannelCount) + (SubOffsetX * ColorChannelCount);
|
||||||
|
int CopySize = SubCopyWidth * ColorChannelCount;
|
||||||
|
mem_copy(&pDestBuffer[ImgOffset], &pSourceBuffer[ImgOffset], CopySize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CGraphics_Threaded::KickCommandBuffer()
|
void CGraphics_Threaded::KickCommandBuffer()
|
||||||
{
|
{
|
||||||
m_pBackend->RunBuffer(m_pCommandBuffer);
|
m_pBackend->RunBuffer(m_pCommandBuffer);
|
||||||
|
|
|
@ -724,143 +724,144 @@ class CGraphics_Threaded : public IEngineGraphics
|
||||||
public:
|
public:
|
||||||
CGraphics_Threaded();
|
CGraphics_Threaded();
|
||||||
|
|
||||||
virtual void ClipEnable(int x, int y, int w, int h);
|
void ClipEnable(int x, int y, int w, int h) override;
|
||||||
virtual void ClipDisable();
|
void ClipDisable() override;
|
||||||
|
|
||||||
virtual void BlendNone();
|
void BlendNone() override;
|
||||||
virtual void BlendNormal();
|
void BlendNormal() override;
|
||||||
virtual void BlendAdditive();
|
void BlendAdditive() override;
|
||||||
|
|
||||||
virtual void WrapNormal();
|
void WrapNormal() override;
|
||||||
virtual void WrapClamp();
|
void WrapClamp() override;
|
||||||
|
|
||||||
virtual int MemoryUsage() const;
|
int MemoryUsage() const override;
|
||||||
|
|
||||||
virtual void MapScreen(float TopLeftX, float TopLeftY, float BottomRightX, float BottomRightY);
|
void MapScreen(float TopLeftX, float TopLeftY, float BottomRightX, float BottomRightY) override;
|
||||||
virtual void GetScreen(float *pTopLeftX, float *pTopLeftY, float *pBottomRightX, float *pBottomRightY);
|
void GetScreen(float *pTopLeftX, float *pTopLeftY, float *pBottomRightX, float *pBottomRightY) override;
|
||||||
|
|
||||||
virtual void LinesBegin();
|
void LinesBegin() override;
|
||||||
virtual void LinesEnd();
|
void LinesEnd() override;
|
||||||
virtual void LinesDraw(const CLineItem *pArray, int Num);
|
void LinesDraw(const CLineItem *pArray, int Num) override;
|
||||||
|
|
||||||
virtual int UnloadTexture(IGraphics::CTextureHandle Index);
|
int UnloadTexture(IGraphics::CTextureHandle Index) override;
|
||||||
virtual IGraphics::CTextureHandle LoadTextureRaw(int Width, int Height, int Format, const void *pData, int StoreFormat, int Flags, const char *pTexName = NULL);
|
IGraphics::CTextureHandle LoadTextureRaw(int Width, int Height, int Format, const void *pData, int StoreFormat, int Flags, const char *pTexName = NULL) override;
|
||||||
virtual int LoadTextureRawSub(IGraphics::CTextureHandle TextureID, int x, int y, int Width, int Height, int Format, const void *pData);
|
int LoadTextureRawSub(IGraphics::CTextureHandle TextureID, int x, int y, int Width, int Height, int Format, const void *pData) override;
|
||||||
|
|
||||||
// simple uncompressed RGBA loaders
|
// simple uncompressed RGBA loaders
|
||||||
virtual IGraphics::CTextureHandle LoadTexture(const char *pFilename, int StorageType, int StoreFormat, int Flags);
|
IGraphics::CTextureHandle LoadTexture(const char *pFilename, int StorageType, int StoreFormat, int Flags) override;
|
||||||
virtual int LoadPNG(CImageInfo *pImg, const char *pFilename, int StorageType);
|
int LoadPNG(CImageInfo *pImg, const char *pFilename, int StorageType) override;
|
||||||
|
|
||||||
|
void CopyTextureBufferSub(uint8_t *pDestBuffer, uint8_t *pSourceBuffer, int FullWidth, int FullHeight, int ColorChannelCount, int SubOffsetX, int SubOffsetY, int SubCopyWidth, int SubCopyHeight) override;
|
||||||
|
|
||||||
void ScreenshotDirect();
|
void ScreenshotDirect();
|
||||||
|
|
||||||
virtual void TextureSet(CTextureHandle TextureID);
|
void TextureSet(CTextureHandle TextureID) override;
|
||||||
|
|
||||||
virtual void Clear(float r, float g, float b);
|
void Clear(float r, float g, float b) override;
|
||||||
|
|
||||||
virtual void QuadsBegin();
|
void QuadsBegin() override;
|
||||||
virtual void QuadsEnd();
|
void QuadsEnd() override;
|
||||||
virtual void TextQuadsBegin();
|
void TextQuadsBegin() override;
|
||||||
virtual void TextQuadsEnd(int TextureSize, int TextTextureIndex, int TextOutlineTextureIndex, float* pOutlineTextColor);
|
void TextQuadsEnd(int TextureSize, int TextTextureIndex, int TextOutlineTextureIndex, float *pOutlineTextColor) override;
|
||||||
virtual void QuadsEndKeepVertices();
|
void QuadsEndKeepVertices() override;
|
||||||
virtual void QuadsDrawCurrentVertices(bool KeepVertices = true);
|
void QuadsDrawCurrentVertices(bool KeepVertices = true) override;
|
||||||
virtual void QuadsSetRotation(float Angle);
|
void QuadsSetRotation(float Angle) override;
|
||||||
|
|
||||||
virtual void SetColorVertex(const CColorVertex *pArray, int Num);
|
void SetColorVertex(const CColorVertex *pArray, int Num) override;
|
||||||
virtual void SetColor(float r, float g, float b, float a);
|
void SetColor(float r, float g, float b, float a) override;
|
||||||
virtual void SetColor(ColorRGBA rgb);
|
void SetColor(ColorRGBA rgb) override;
|
||||||
virtual void SetColor4(vec4 TopLeft, vec4 TopRight, vec4 BottomLeft, vec4 BottomRight);
|
void SetColor4(vec4 TopLeft, vec4 TopRight, vec4 BottomLeft, vec4 BottomRight) override;
|
||||||
|
|
||||||
// go through all vertices and change their color (only works for quads)
|
// go through all vertices and change their color (only works for quads)
|
||||||
virtual void ChangeColorOfCurrentQuadVertices(float r, float g, float b, float a);
|
void ChangeColorOfCurrentQuadVertices(float r, float g, float b, float a) override;
|
||||||
virtual void ChangeColorOfQuadVertices(int QuadOffset, unsigned char r, unsigned char g, unsigned char b, unsigned char a);
|
void ChangeColorOfQuadVertices(int QuadOffset, unsigned char r, unsigned char g, unsigned char b, unsigned char a) override;
|
||||||
|
|
||||||
void SetColor(CCommandBuffer::SVertex *pVertex, int ColorIndex);
|
void SetColor(CCommandBuffer::SVertex *pVertex, int ColorIndex);
|
||||||
|
|
||||||
virtual void QuadsSetSubset(float TlU, float TlV, float BrU, float BrV);
|
void QuadsSetSubset(float TlU, float TlV, float BrU, float BrV) override;
|
||||||
virtual void QuadsSetSubsetFree(
|
void QuadsSetSubsetFree(
|
||||||
float x0, float y0, float x1, float y1,
|
float x0, float y0, float x1, float y1,
|
||||||
float x2, float y2, float x3, float y3);
|
float x2, float y2, float x3, float y3) override;
|
||||||
|
|
||||||
virtual void QuadsDraw(CQuadItem *pArray, int Num);
|
void QuadsDraw(CQuadItem *pArray, int Num) override;
|
||||||
virtual void QuadsDrawTL(const CQuadItem *pArray, int Num);
|
void QuadsDrawTL(const CQuadItem *pArray, int Num) override;
|
||||||
virtual void QuadsDrawFreeform(const CFreeformItem *pArray, int Num);
|
void QuadsDrawFreeform(const CFreeformItem *pArray, int Num) override;
|
||||||
virtual void QuadsText(float x, float y, float Size, const char *pText);
|
void QuadsText(float x, float y, float Size, const char *pText) override;
|
||||||
|
|
||||||
virtual int CreateQuadContainer();
|
int CreateQuadContainer() override;
|
||||||
virtual void QuadContainerUpload(int ContainerIndex);
|
void QuadContainerUpload(int ContainerIndex) override;
|
||||||
virtual void QuadContainerAddQuads(int ContainerIndex, CQuadItem *pArray, int Num);
|
void QuadContainerAddQuads(int ContainerIndex, CQuadItem *pArray, int Num) override;
|
||||||
virtual void QuadContainerAddQuads(int ContainerIndex, CFreeformItem *pArray, int Num);
|
void QuadContainerAddQuads(int ContainerIndex, CFreeformItem *pArray, int Num) override;
|
||||||
virtual void QuadContainerReset(int ContainerIndex);
|
void QuadContainerReset(int ContainerIndex) override;
|
||||||
virtual void DeleteQuadContainer(int ContainerIndex);
|
void DeleteQuadContainer(int ContainerIndex) override;
|
||||||
virtual void RenderQuadContainer(int ContainerIndex, int QuadDrawNum);
|
void RenderQuadContainer(int ContainerIndex, int QuadDrawNum) override;
|
||||||
virtual void RenderQuadContainer(int ContainerIndex, int QuadOffset, int QuadDrawNum);
|
void RenderQuadContainer(int ContainerIndex, int QuadOffset, int QuadDrawNum) override;
|
||||||
virtual void RenderQuadContainerAsSprite(int ContainerIndex, int QuadOffset, float X, float Y, float ScaleX = 1.f, float ScaleY = 1.f);
|
void RenderQuadContainerAsSprite(int ContainerIndex, int QuadOffset, float X, float Y, float ScaleX = 1.f, float ScaleY = 1.f) override;
|
||||||
virtual void RenderQuadContainerAsSpriteMultiple(int ContainerIndex, int QuadOffset, int DrawCount, SRenderSpriteInfo *pRenderInfo);
|
void RenderQuadContainerAsSpriteMultiple(int ContainerIndex, int QuadOffset, int DrawCount, SRenderSpriteInfo *pRenderInfo) override;
|
||||||
|
|
||||||
virtual void FlushVertices(bool KeepVertices = false);
|
void FlushVertices(bool KeepVertices = false) override;
|
||||||
virtual void FlushTextVertices(int TextureSize, int TextTextureIndex, int TextOutlineTextureIndex, float *pOutlineTextColor);
|
void FlushTextVertices(int TextureSize, int TextTextureIndex, int TextOutlineTextureIndex, float *pOutlineTextColor) override;
|
||||||
|
|
||||||
virtual void RenderTileLayer(int BufferContainerIndex, float *pColor, char **pOffsets, unsigned int *IndicedVertexDrawNum, size_t NumIndicesOffet);
|
void RenderTileLayer(int BufferContainerIndex, float *pColor, char **pOffsets, unsigned int *IndicedVertexDrawNum, size_t NumIndicesOffet) override;
|
||||||
virtual void RenderBorderTiles(int BufferContainerIndex, float *pColor, char *pIndexBufferOffset, float *pOffset, float *pDir, int JumpIndex, unsigned int DrawNum);
|
void RenderBorderTiles(int BufferContainerIndex, float *pColor, char *pIndexBufferOffset, float *pOffset, float *pDir, int JumpIndex, unsigned int DrawNum) override;
|
||||||
virtual void RenderBorderTileLines(int BufferContainerIndex, float *pColor, char *pIndexBufferOffset, float *pOffset, float *pDir, unsigned int IndexDrawNum, unsigned int RedrawNum);
|
void RenderBorderTileLines(int BufferContainerIndex, float *pColor, char *pIndexBufferOffset, float *pOffset, float *pDir, unsigned int IndexDrawNum, unsigned int RedrawNum) override;
|
||||||
virtual void RenderQuadLayer(int BufferContainerIndex, SQuadRenderInfo* pQuadInfo, int QuadNum);
|
void RenderQuadLayer(int BufferContainerIndex, SQuadRenderInfo *pQuadInfo, int QuadNum) override;
|
||||||
virtual void RenderText(int BufferContainerIndex, int TextQuadNum, int TextureSize, int TextureTextIndex, int TextureTextOutlineIndex, float* pTextColor, float* pTextoutlineColor);
|
void RenderText(int BufferContainerIndex, int TextQuadNum, int TextureSize, int TextureTextIndex, int TextureTextOutlineIndex, float *pTextColor, float *pTextoutlineColor) override;
|
||||||
|
|
||||||
// opengl 3.3 functions
|
// opengl 3.3 functions
|
||||||
virtual int CreateBufferObject(size_t UploadDataSize, void* pUploadData);
|
int CreateBufferObject(size_t UploadDataSize, void *pUploadData) override;
|
||||||
virtual void RecreateBufferObject(int BufferIndex, size_t UploadDataSize, void* pUploadData);
|
void RecreateBufferObject(int BufferIndex, size_t UploadDataSize, void *pUploadData) override;
|
||||||
virtual void UpdateBufferObject(int BufferIndex, size_t UploadDataSize, void* pUploadData, void* pOffset);
|
void UpdateBufferObject(int BufferIndex, size_t UploadDataSize, void *pUploadData, void *pOffset) override;
|
||||||
virtual void CopyBufferObject(int WriteBufferIndex, int ReadBufferIndex, size_t WriteOffset, size_t ReadOffset, size_t CopyDataSize);
|
void CopyBufferObject(int WriteBufferIndex, int ReadBufferIndex, size_t WriteOffset, size_t ReadOffset, size_t CopyDataSize) override;
|
||||||
virtual void DeleteBufferObject(int BufferIndex);
|
void DeleteBufferObject(int BufferIndex) override;
|
||||||
|
|
||||||
virtual int CreateBufferContainer(SBufferContainerInfo *pContainerInfo);
|
int CreateBufferContainer(SBufferContainerInfo *pContainerInfo) override;
|
||||||
// destroying all buffer objects means, that all referenced VBOs are destroyed automatically, so the user does not need to save references to them
|
// destroying all buffer objects means, that all referenced VBOs are destroyed automatically, so the user does not need to save references to them
|
||||||
virtual void DeleteBufferContainer(int ContainerIndex, bool DestroyAllBO = true);
|
void DeleteBufferContainer(int ContainerIndex, bool DestroyAllBO = true) override;
|
||||||
virtual void UpdateBufferContainer(int ContainerIndex, SBufferContainerInfo *pContainerInfo);
|
void UpdateBufferContainer(int ContainerIndex, SBufferContainerInfo *pContainerInfo) override;
|
||||||
virtual void IndicesNumRequiredNotify(unsigned int RequiredIndicesCount);
|
void IndicesNumRequiredNotify(unsigned int RequiredIndicesCount) override;
|
||||||
|
|
||||||
|
int GetNumScreens() const override;
|
||||||
|
void Minimize() override;
|
||||||
|
void Maximize() override;
|
||||||
|
bool Fullscreen(bool State) override;
|
||||||
|
void SetWindowBordered(bool State) override;
|
||||||
|
bool SetWindowScreen(int Index) override;
|
||||||
|
void Resize(int w, int h) override;
|
||||||
|
void AddWindowResizeListener(WINDOW_RESIZE_FUNC pFunc, void *pUser) override;
|
||||||
|
int GetWindowScreen() override;
|
||||||
|
|
||||||
virtual int GetNumScreens() const;
|
int WindowActive() override;
|
||||||
virtual void Minimize();
|
int WindowOpen() override;
|
||||||
virtual void Maximize();
|
|
||||||
virtual bool Fullscreen(bool State);
|
|
||||||
virtual void SetWindowBordered(bool State);
|
|
||||||
virtual bool SetWindowScreen(int Index);
|
|
||||||
virtual void Resize(int w, int h);
|
|
||||||
virtual void AddWindowResizeListener(WINDOW_RESIZE_FUNC pFunc, void *pUser);
|
|
||||||
virtual int GetWindowScreen();
|
|
||||||
|
|
||||||
virtual int WindowActive();
|
void SetWindowGrab(bool Grab) override;
|
||||||
virtual int WindowOpen();
|
void NotifyWindow() override;
|
||||||
|
|
||||||
virtual void SetWindowGrab(bool Grab);
|
int Init() override;
|
||||||
virtual void NotifyWindow();
|
void Shutdown() override;
|
||||||
|
|
||||||
virtual int Init();
|
void TakeScreenshot(const char *pFilename) override;
|
||||||
virtual void Shutdown();
|
void TakeCustomScreenshot(const char *pFilename) override;
|
||||||
|
void Swap() override;
|
||||||
|
bool SetVSync(bool State) override;
|
||||||
|
|
||||||
virtual void TakeScreenshot(const char *pFilename);
|
int GetVideoModes(CVideoMode *pModes, int MaxModes, int Screen) override;
|
||||||
virtual void TakeCustomScreenshot(const char *pFilename);
|
|
||||||
virtual void Swap();
|
|
||||||
virtual bool SetVSync(bool State);
|
|
||||||
|
|
||||||
virtual int GetVideoModes(CVideoMode *pModes, int MaxModes, int Screen);
|
|
||||||
|
|
||||||
virtual int GetDesktopScreenWidth() { return m_DesktopScreenWidth; }
|
virtual int GetDesktopScreenWidth() { return m_DesktopScreenWidth; }
|
||||||
virtual int GetDesktopScreenHeight() { return m_DesktopScreenHeight; }
|
virtual int GetDesktopScreenHeight() { return m_DesktopScreenHeight; }
|
||||||
|
|
||||||
// synchronization
|
// synchronization
|
||||||
virtual void InsertSignal(semaphore *pSemaphore);
|
void InsertSignal(semaphore *pSemaphore) override;
|
||||||
virtual bool IsIdle();
|
bool IsIdle() override;
|
||||||
virtual void WaitForIdle();
|
void WaitForIdle() override;
|
||||||
|
|
||||||
virtual SGraphicsWarning *GetCurWarning();
|
SGraphicsWarning *GetCurWarning() override;
|
||||||
|
|
||||||
virtual bool IsTileBufferingEnabled() { return m_OpenGLTileBufferingEnabled; }
|
bool IsTileBufferingEnabled() override { return m_OpenGLTileBufferingEnabled; }
|
||||||
virtual bool IsQuadBufferingEnabled() { return m_OpenGLQuadBufferingEnabled; }
|
bool IsQuadBufferingEnabled() override { return m_OpenGLQuadBufferingEnabled; }
|
||||||
virtual bool IsTextBufferingEnabled() { return m_OpenGLTextBufferingEnabled; }
|
bool IsTextBufferingEnabled() override { return m_OpenGLTextBufferingEnabled; }
|
||||||
virtual bool IsQuadContainerBufferingEnabled() { return m_OpenGLQuadContainerBufferingEnabled; }
|
bool IsQuadContainerBufferingEnabled() override { return m_OpenGLQuadContainerBufferingEnabled; }
|
||||||
virtual bool HasTextureArrays() { return m_OpenGLHasTextureArrays; }
|
bool HasTextureArrays() override { return m_OpenGLHasTextureArrays; }
|
||||||
};
|
};
|
||||||
|
|
||||||
extern IGraphicsBackend *CreateGraphicsBackend();
|
extern IGraphicsBackend *CreateGraphicsBackend();
|
||||||
|
|
|
@ -193,6 +193,9 @@ public:
|
||||||
|
|
||||||
virtual int LoadPNG(CImageInfo *pImg, const char *pFilename, int StorageType) = 0;
|
virtual int LoadPNG(CImageInfo *pImg, const char *pFilename, int StorageType) = 0;
|
||||||
|
|
||||||
|
// destination and source buffer require to have the same width and height
|
||||||
|
virtual void CopyTextureBufferSub(uint8_t *pDestBuffer, uint8_t *pSourceBuffer, int FullWidth, int FullHeight, int ColorChannelCount, int SubOffsetX, int SubOffsetY, int SubCopyWidth, int SubCopyHeight) = 0;
|
||||||
|
|
||||||
virtual int UnloadTexture(CTextureHandle Index) = 0;
|
virtual int UnloadTexture(CTextureHandle Index) = 0;
|
||||||
virtual CTextureHandle LoadTextureRaw(int Width, int Height, int Format, const void *pData, int StoreFormat, int Flags, const char *pTexName = NULL) = 0;
|
virtual CTextureHandle LoadTextureRaw(int Width, int Height, int Format, const void *pData, int StoreFormat, int Flags, const char *pTexName = NULL) = 0;
|
||||||
virtual int LoadTextureRawSub(CTextureHandle TextureID, int x, int y, int Width, int Height, int Format, const void *pData) = 0;
|
virtual int LoadTextureRawSub(CTextureHandle TextureID, int x, int y, int Width, int Height, int Format, const void *pData) = 0;
|
||||||
|
|
|
@ -31,6 +31,8 @@ public:
|
||||||
virtual const char *InsertTimestampAsUtc() const = 0;
|
virtual const char *InsertTimestampAsUtc() const = 0;
|
||||||
// can be used in the context of `LIKE Map`, adds `? COLLATE`
|
// can be used in the context of `LIKE Map`, adds `? COLLATE`
|
||||||
virtual const char *CollateNocase() const = 0;
|
virtual const char *CollateNocase() const = 0;
|
||||||
|
// syntax to insert a row into table or ignore if it already exists
|
||||||
|
virtual const char *InsertIgnore() const = 0;
|
||||||
|
|
||||||
enum Status
|
enum Status
|
||||||
{
|
{
|
||||||
|
@ -56,6 +58,8 @@ public:
|
||||||
virtual void BindInt(int Idx, int Value) = 0;
|
virtual void BindInt(int Idx, int Value) = 0;
|
||||||
virtual void BindFloat(int Idx, float Value) = 0;
|
virtual void BindFloat(int Idx, float Value) = 0;
|
||||||
|
|
||||||
|
// Print expanded sql statement
|
||||||
|
virtual void Print() = 0;
|
||||||
// executes the query and returns if a result row exists and selects it
|
// executes the query and returns if a result row exists and selects it
|
||||||
// when called multiple times the next row is selected
|
// when called multiple times the next row is selected
|
||||||
virtual bool Step() = 0;
|
virtual bool Step() = 0;
|
||||||
|
@ -67,8 +71,6 @@ public:
|
||||||
virtual void GetString(int Col, char *pBuffer, int BufferSize) const = 0;
|
virtual void GetString(int Col, char *pBuffer, int BufferSize) const = 0;
|
||||||
// returns number of bytes read into the buffer
|
// returns number of bytes read into the buffer
|
||||||
virtual int GetBlob(int Col, unsigned char *pBuffer, int BufferSize) const = 0;
|
virtual int GetBlob(int Col, unsigned char *pBuffer, int BufferSize) const = 0;
|
||||||
// syntax to insert a row into table or ignore if it already exists
|
|
||||||
virtual const char *GetInsertIgnore() const = 0;
|
|
||||||
|
|
||||||
// SQL statements, that can't be abstracted, has side effects to the result
|
// SQL statements, that can't be abstracted, has side effects to the result
|
||||||
virtual void AddPoints(const char *pPlayer, int Points) = 0;
|
virtual void AddPoints(const char *pPlayer, int Points) = 0;
|
||||||
|
|
|
@ -312,11 +312,6 @@ int CMysqlConnection::GetBlob(int Col, unsigned char *pBuffer, int BufferSize) c
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *CMysqlConnection::GetInsertIgnore() const
|
|
||||||
{
|
|
||||||
return "INSERT IGNORE";
|
|
||||||
}
|
|
||||||
|
|
||||||
void CMysqlConnection::AddPoints(const char *pPlayer, int Points)
|
void CMysqlConnection::AddPoints(const char *pPlayer, int Points)
|
||||||
{
|
{
|
||||||
char aBuf[512];
|
char aBuf[512];
|
||||||
|
|
|
@ -33,6 +33,7 @@ public:
|
||||||
virtual void ToUnixTimestamp(const char *pTimestamp, char *aBuf, unsigned int BufferSize);
|
virtual void ToUnixTimestamp(const char *pTimestamp, char *aBuf, unsigned int BufferSize);
|
||||||
virtual const char *InsertTimestampAsUtc() const { return "?"; }
|
virtual const char *InsertTimestampAsUtc() const { return "?"; }
|
||||||
virtual const char *CollateNocase() const { return "CONVERT(? USING utf8mb4) COLLATE utf8mb4_general_ci"; }
|
virtual const char *CollateNocase() const { return "CONVERT(? USING utf8mb4) COLLATE utf8mb4_general_ci"; }
|
||||||
|
virtual const char *InsertIgnore() const { return "INSERT IGNORE"; };
|
||||||
|
|
||||||
virtual Status Connect();
|
virtual Status Connect();
|
||||||
virtual void Disconnect();
|
virtual void Disconnect();
|
||||||
|
@ -47,6 +48,7 @@ public:
|
||||||
virtual void BindInt(int Idx, int Value);
|
virtual void BindInt(int Idx, int Value);
|
||||||
virtual void BindFloat(int Idx, float Value);
|
virtual void BindFloat(int Idx, float Value);
|
||||||
|
|
||||||
|
virtual void Print() {}
|
||||||
virtual bool Step();
|
virtual bool Step();
|
||||||
|
|
||||||
virtual bool IsNull(int Col) const;
|
virtual bool IsNull(int Col) const;
|
||||||
|
@ -54,7 +56,6 @@ public:
|
||||||
virtual int GetInt(int Col) const;
|
virtual int GetInt(int Col) const;
|
||||||
virtual void GetString(int Col, char *pBuffer, int BufferSize) const;
|
virtual void GetString(int Col, char *pBuffer, int BufferSize) const;
|
||||||
virtual int GetBlob(int Col, unsigned char *pBuffer, int BufferSize) const;
|
virtual int GetBlob(int Col, unsigned char *pBuffer, int BufferSize) const;
|
||||||
virtual const char *GetInsertIgnore() const;
|
|
||||||
|
|
||||||
virtual void AddPoints(const char *pPlayer, int Points);
|
virtual void AddPoints(const char *pPlayer, int Points);
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,6 @@ CSqliteConnection::~CSqliteConnection()
|
||||||
m_pDb = nullptr;
|
m_pDb = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CSqliteConnection::Print(IConsole *pConsole, const char *Mode)
|
void CSqliteConnection::Print(IConsole *pConsole, const char *Mode)
|
||||||
{
|
{
|
||||||
char aBuf[512];
|
char aBuf[512];
|
||||||
|
@ -36,7 +35,6 @@ void CSqliteConnection::Print(IConsole *pConsole, const char *Mode)
|
||||||
pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf);
|
pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CSqliteConnection::ToUnixTimestamp(const char *pTimestamp, char *aBuf, unsigned int BufferSize)
|
void CSqliteConnection::ToUnixTimestamp(const char *pTimestamp, char *aBuf, unsigned int BufferSize)
|
||||||
{
|
{
|
||||||
str_format(aBuf, BufferSize, "strftime('%%s', %s)", pTimestamp);
|
str_format(aBuf, BufferSize, "strftime('%%s', %s)", pTimestamp);
|
||||||
|
@ -156,6 +154,17 @@ void CSqliteConnection::BindFloat(int Idx, float Value)
|
||||||
m_Done = false;
|
m_Done = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO(2020-09-07): remove extern declaration, when all supported systems ship SQLite3 version 3.14 or above
|
||||||
|
#if defined(__GNUC__)
|
||||||
|
extern char *sqlite3_expanded_sql(sqlite3_stmt *pStmt) __attribute__((weak));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void CSqliteConnection::Print()
|
||||||
|
{
|
||||||
|
if(m_pStmt != nullptr && sqlite3_expanded_sql != nullptr)
|
||||||
|
dbg_msg("sql", "SQLite statement: %s", sqlite3_expanded_sql(m_pStmt));
|
||||||
|
}
|
||||||
|
|
||||||
bool CSqliteConnection::Step()
|
bool CSqliteConnection::Step()
|
||||||
{
|
{
|
||||||
if(m_Done)
|
if(m_Done)
|
||||||
|
@ -205,11 +214,6 @@ int CSqliteConnection::GetBlob(int Col, unsigned char *pBuffer, int BufferSize)
|
||||||
return Size;
|
return Size;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *CSqliteConnection::GetInsertIgnore() const
|
|
||||||
{
|
|
||||||
return "INSERT OR IGNORE";
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CSqliteConnection::Execute(const char *pQuery)
|
bool CSqliteConnection::Execute(const char *pQuery)
|
||||||
{
|
{
|
||||||
char *pErrorMsg;
|
char *pErrorMsg;
|
||||||
|
|
|
@ -20,6 +20,7 @@ public:
|
||||||
virtual void ToUnixTimestamp(const char *pTimestamp, char *aBuf, unsigned int BufferSize);
|
virtual void ToUnixTimestamp(const char *pTimestamp, char *aBuf, unsigned int BufferSize);
|
||||||
virtual const char *InsertTimestampAsUtc() const { return "DATETIME(?, 'utc')"; }
|
virtual const char *InsertTimestampAsUtc() const { return "DATETIME(?, 'utc')"; }
|
||||||
virtual const char *CollateNocase() const { return "? COLLATE NOCASE"; }
|
virtual const char *CollateNocase() const { return "? COLLATE NOCASE"; }
|
||||||
|
virtual const char *InsertIgnore() const { return "INSERT OR IGNORE"; };
|
||||||
|
|
||||||
virtual Status Connect();
|
virtual Status Connect();
|
||||||
virtual void Disconnect();
|
virtual void Disconnect();
|
||||||
|
@ -34,6 +35,7 @@ public:
|
||||||
virtual void BindInt(int Idx, int Value);
|
virtual void BindInt(int Idx, int Value);
|
||||||
virtual void BindFloat(int Idx, float Value);
|
virtual void BindFloat(int Idx, float Value);
|
||||||
|
|
||||||
|
virtual void Print();
|
||||||
virtual bool Step();
|
virtual bool Step();
|
||||||
|
|
||||||
virtual bool IsNull(int Col) const;
|
virtual bool IsNull(int Col) const;
|
||||||
|
@ -42,7 +44,6 @@ public:
|
||||||
virtual void GetString(int Col, char *pBuffer, int BufferSize) const;
|
virtual void GetString(int Col, char *pBuffer, int BufferSize) const;
|
||||||
// passing a negative buffer size is undefined behavior
|
// passing a negative buffer size is undefined behavior
|
||||||
virtual int GetBlob(int Col, unsigned char *pBuffer, int BufferSize) const;
|
virtual int GetBlob(int Col, unsigned char *pBuffer, int BufferSize) const;
|
||||||
virtual const char *GetInsertIgnore() const;
|
|
||||||
|
|
||||||
virtual void AddPoints(const char *pPlayer, int Points);
|
virtual void AddPoints(const char *pPlayer, int Points);
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ CMapImages::CMapImages(int TextureSize)
|
||||||
{
|
{
|
||||||
m_Count = 0;
|
m_Count = 0;
|
||||||
m_TextureScale = TextureSize;
|
m_TextureScale = TextureSize;
|
||||||
m_EntitiesIsLoaded = false;
|
mem_zero(m_EntitiesIsLoaded, sizeof(m_EntitiesIsLoaded));
|
||||||
m_SpeedupArrowIsLoaded = false;
|
m_SpeedupArrowIsLoaded = false;
|
||||||
|
|
||||||
mem_zero(m_aTextureUsedByTileOrQuadLayerFlag, sizeof(m_aTextureUsedByTileOrQuadLayerFlag));
|
mem_zero(m_aTextureUsedByTileOrQuadLayerFlag, sizeof(m_aTextureUsedByTileOrQuadLayerFlag));
|
||||||
|
@ -59,7 +59,7 @@ void CMapImages::OnMapLoadImpl(class CLayers *pLayers, IMap *pMap)
|
||||||
CMapItemLayerTilemap *pTLayer = (CMapItemLayerTilemap *)pLayer;
|
CMapItemLayerTilemap *pTLayer = (CMapItemLayerTilemap *)pLayer;
|
||||||
if(pTLayer->m_Image != -1 && pTLayer->m_Image < (int)(sizeof(m_aTextures) / sizeof(m_aTextures[0])))
|
if(pTLayer->m_Image != -1 && pTLayer->m_Image < (int)(sizeof(m_aTextures) / sizeof(m_aTextures[0])))
|
||||||
{
|
{
|
||||||
m_aTextureUsedByTileOrQuadLayerFlag[(size_t)pTLayer->m_Image] |= 1;
|
m_aTextureUsedByTileOrQuadLayerFlag[pTLayer->m_Image] |= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(pLayer->m_Type == LAYERTYPE_QUADS)
|
else if(pLayer->m_Type == LAYERTYPE_QUADS)
|
||||||
|
@ -67,7 +67,7 @@ void CMapImages::OnMapLoadImpl(class CLayers *pLayers, IMap *pMap)
|
||||||
CMapItemLayerQuads *pQLayer = (CMapItemLayerQuads *)pLayer;
|
CMapItemLayerQuads *pQLayer = (CMapItemLayerQuads *)pLayer;
|
||||||
if(pQLayer->m_Image != -1 && pQLayer->m_Image < (int)(sizeof(m_aTextures) / sizeof(m_aTextures[0])))
|
if(pQLayer->m_Image != -1 && pQLayer->m_Image < (int)(sizeof(m_aTextures) / sizeof(m_aTextures[0])))
|
||||||
{
|
{
|
||||||
m_aTextureUsedByTileOrQuadLayerFlag[(size_t)pQLayer->m_Image] |= 2;
|
m_aTextureUsedByTileOrQuadLayerFlag[pQLayer->m_Image] |= 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,36 +111,201 @@ void CMapImages::LoadBackground(class CLayers *pLayers, class IMap *pMap)
|
||||||
OnMapLoadImpl(pLayers, pMap);
|
OnMapLoadImpl(pLayers, pMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
IGraphics::CTextureHandle CMapImages::GetEntities()
|
bool CMapImages::HasFrontLayer()
|
||||||
{
|
{
|
||||||
// DDNet default to prevent delay in seeing entities
|
return GameClient()->m_GameInfo.m_EntitiesDDNet || GameClient()->m_GameInfo.m_EntitiesDDRace;
|
||||||
const char *pEntities = "ddnet";
|
}
|
||||||
if(GameClient()->m_GameInfo.m_EntitiesDDNet)
|
|
||||||
pEntities = "ddnet";
|
|
||||||
else if(GameClient()->m_GameInfo.m_EntitiesDDRace)
|
|
||||||
pEntities = "ddrace";
|
|
||||||
else if(GameClient()->m_GameInfo.m_EntitiesRace)
|
|
||||||
pEntities = "race";
|
|
||||||
else if (GameClient()->m_GameInfo.m_EntitiesBW)
|
|
||||||
pEntities = "blockworlds";
|
|
||||||
else if(GameClient()->m_GameInfo.m_EntitiesFNG)
|
|
||||||
pEntities = "fng";
|
|
||||||
else if(GameClient()->m_GameInfo.m_EntitiesVanilla)
|
|
||||||
pEntities = "vanilla";
|
|
||||||
|
|
||||||
if(!m_EntitiesIsLoaded || m_pEntitiesGameType != pEntities)
|
bool CMapImages::HasSpeedupLayer()
|
||||||
|
{
|
||||||
|
return GameClient()->m_GameInfo.m_EntitiesDDNet || GameClient()->m_GameInfo.m_EntitiesDDRace;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CMapImages::HasSwitchLayer()
|
||||||
|
{
|
||||||
|
return GameClient()->m_GameInfo.m_EntitiesDDNet || GameClient()->m_GameInfo.m_EntitiesDDRace;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CMapImages::HasTeleLayer()
|
||||||
|
{
|
||||||
|
return GameClient()->m_GameInfo.m_EntitiesDDNet || GameClient()->m_GameInfo.m_EntitiesDDRace;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CMapImages::HasTuneLayer()
|
||||||
|
{
|
||||||
|
return GameClient()->m_GameInfo.m_EntitiesDDNet || GameClient()->m_GameInfo.m_EntitiesDDRace;
|
||||||
|
}
|
||||||
|
|
||||||
|
IGraphics::CTextureHandle CMapImages::GetEntities(EMapImageEntityLayerType EntityLayerType)
|
||||||
|
{
|
||||||
|
const char *pEntities = "ddnet";
|
||||||
|
EMapImageModType EntitiesModType = MAP_IMAGE_MOD_TYPE_UNKNOWN;
|
||||||
|
bool EntitesAreMasked = !GameClient()->m_GameInfo.m_DontMaskEntities;
|
||||||
|
|
||||||
|
if(GameClient()->m_GameInfo.m_EntitiesDDNet && EntitesAreMasked)
|
||||||
{
|
{
|
||||||
|
pEntities = "ddnet";
|
||||||
|
EntitiesModType = MAP_IMAGE_MOD_TYPE_DDNET;
|
||||||
|
}
|
||||||
|
else if(GameClient()->m_GameInfo.m_EntitiesDDRace && EntitesAreMasked)
|
||||||
|
{
|
||||||
|
pEntities = "ddrace";
|
||||||
|
EntitiesModType = MAP_IMAGE_MOD_TYPE_DDRACE;
|
||||||
|
}
|
||||||
|
else if(GameClient()->m_GameInfo.m_EntitiesRace)
|
||||||
|
{
|
||||||
|
pEntities = "race";
|
||||||
|
EntitiesModType = MAP_IMAGE_MOD_TYPE_RACE;
|
||||||
|
}
|
||||||
|
else if(GameClient()->m_GameInfo.m_EntitiesBW)
|
||||||
|
{
|
||||||
|
pEntities = "blockworlds";
|
||||||
|
EntitiesModType = MAP_IMAGE_MOD_TYPE_BLOCKWORLDS;
|
||||||
|
}
|
||||||
|
else if(GameClient()->m_GameInfo.m_EntitiesFNG)
|
||||||
|
{
|
||||||
|
pEntities = "fng";
|
||||||
|
EntitiesModType = MAP_IMAGE_MOD_TYPE_FNG;
|
||||||
|
}
|
||||||
|
else if(GameClient()->m_GameInfo.m_EntitiesVanilla)
|
||||||
|
{
|
||||||
|
pEntities = "vanilla";
|
||||||
|
EntitiesModType = MAP_IMAGE_MOD_TYPE_VANILLA;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!m_EntitiesIsLoaded[EntitiesModType])
|
||||||
|
{
|
||||||
|
m_EntitiesIsLoaded[EntitiesModType] = true;
|
||||||
|
|
||||||
|
bool WasUnknwon = EntitiesModType == MAP_IMAGE_MOD_TYPE_UNKNOWN;
|
||||||
|
|
||||||
char aPath[64];
|
char aPath[64];
|
||||||
str_format(aPath, sizeof(aPath), "editor/entities_clear/%s.png", pEntities);
|
str_format(aPath, sizeof(aPath), "editor/entities_clear/%s.png", pEntities);
|
||||||
|
|
||||||
if(m_EntitiesTextures >= 0)
|
bool GameTypeHasFrontLayer = HasFrontLayer() || WasUnknwon;
|
||||||
Graphics()->UnloadTexture(m_EntitiesTextures);
|
bool GameTypeHasSpeedupLayer = HasSpeedupLayer() || WasUnknwon;
|
||||||
|
bool GameTypeHasSwitchLayer = HasSwitchLayer() || WasUnknwon;
|
||||||
|
bool GameTypeHasTeleLayer = HasTeleLayer() || WasUnknwon;
|
||||||
|
bool GameTypeHasTuneLayer = HasTuneLayer() || WasUnknwon;
|
||||||
|
|
||||||
int TextureLoadFlag = Graphics()->HasTextureArrays() ? IGraphics::TEXLOAD_TO_2D_ARRAY_TEXTURE : IGraphics::TEXLOAD_TO_3D_TEXTURE;
|
int TextureLoadFlag = Graphics()->HasTextureArrays() ? IGraphics::TEXLOAD_TO_2D_ARRAY_TEXTURE : IGraphics::TEXLOAD_TO_3D_TEXTURE;
|
||||||
m_EntitiesTextures = Graphics()->LoadTexture(aPath, IStorage::TYPE_ALL, CImageInfo::FORMAT_AUTO, TextureLoadFlag);
|
|
||||||
m_EntitiesIsLoaded = true;
|
CImageInfo ImgInfo;
|
||||||
m_pEntitiesGameType = pEntities;
|
if(Graphics()->LoadPNG(&ImgInfo, aPath, IStorage::TYPE_ALL) && ImgInfo.m_Width > 0 && ImgInfo.m_Height > 0)
|
||||||
|
{
|
||||||
|
int ColorChannelCount = 0;
|
||||||
|
if(ImgInfo.m_Format == CImageInfo::FORMAT_ALPHA)
|
||||||
|
ColorChannelCount = 1;
|
||||||
|
else if(ImgInfo.m_Format == CImageInfo::FORMAT_RGB)
|
||||||
|
ColorChannelCount = 3;
|
||||||
|
else if(ImgInfo.m_Format == CImageInfo::FORMAT_RGBA)
|
||||||
|
ColorChannelCount = 4;
|
||||||
|
|
||||||
|
int BuildImageSize = ColorChannelCount * ImgInfo.m_Width * ImgInfo.m_Height;
|
||||||
|
|
||||||
|
uint8_t *pTmpImgData = (uint8_t *)ImgInfo.m_pData;
|
||||||
|
uint8_t *pBuildImgData = (uint8_t *)malloc(BuildImageSize);
|
||||||
|
|
||||||
|
// build game layer
|
||||||
|
for(int n = 0; n < MAP_IMAGE_ENTITY_LAYER_TYPE_COUNT; ++n)
|
||||||
|
{
|
||||||
|
bool BuildThisLayer = true;
|
||||||
|
if(n == MAP_IMAGE_ENTITY_LAYER_TYPE_FRONT && !GameTypeHasFrontLayer)
|
||||||
|
BuildThisLayer = false;
|
||||||
|
else if(n == MAP_IMAGE_ENTITY_LAYER_TYPE_SPEEDUP && !GameTypeHasSpeedupLayer)
|
||||||
|
BuildThisLayer = false;
|
||||||
|
else if(n == MAP_IMAGE_ENTITY_LAYER_TYPE_SWITCH && !GameTypeHasSwitchLayer)
|
||||||
|
BuildThisLayer = false;
|
||||||
|
else if(n == MAP_IMAGE_ENTITY_LAYER_TYPE_TELE && !GameTypeHasTeleLayer)
|
||||||
|
BuildThisLayer = false;
|
||||||
|
else if(n == MAP_IMAGE_ENTITY_LAYER_TYPE_TUNE && !GameTypeHasTuneLayer)
|
||||||
|
BuildThisLayer = false;
|
||||||
|
|
||||||
|
dbg_assert(m_EntitiesTextures[EntitiesModType][n] == -1, "entities texture already loaded when it should not be");
|
||||||
|
|
||||||
|
if(BuildThisLayer)
|
||||||
|
{
|
||||||
|
// set everything transparent
|
||||||
|
mem_zero(pBuildImgData, BuildImageSize);
|
||||||
|
|
||||||
|
for(int i = 0; i < 256; ++i)
|
||||||
|
{
|
||||||
|
bool ValidTile = i != 0;
|
||||||
|
int TileIndex = i;
|
||||||
|
if(EntitiesModType == MAP_IMAGE_MOD_TYPE_DDNET || EntitiesModType == MAP_IMAGE_MOD_TYPE_DDRACE)
|
||||||
|
{
|
||||||
|
if(EntitiesModType == MAP_IMAGE_MOD_TYPE_DDNET || TileIndex != TILE_BOOST)
|
||||||
|
{
|
||||||
|
if(n == MAP_IMAGE_ENTITY_LAYER_TYPE_GAME && !IsValidGameTile((int)TileIndex))
|
||||||
|
ValidTile = false;
|
||||||
|
else if(n == MAP_IMAGE_ENTITY_LAYER_TYPE_FRONT && !IsValidFrontTile((int)TileIndex))
|
||||||
|
ValidTile = false;
|
||||||
|
else if(n == MAP_IMAGE_ENTITY_LAYER_TYPE_SPEEDUP && !IsValidSpeedupTile((int)TileIndex))
|
||||||
|
ValidTile = false;
|
||||||
|
else if(n == MAP_IMAGE_ENTITY_LAYER_TYPE_SWITCH)
|
||||||
|
{
|
||||||
|
if(!IsValidSwitchTile((int)TileIndex))
|
||||||
|
ValidTile = false;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(TileIndex == TILE_SWITCHTIMEDOPEN)
|
||||||
|
TileIndex = 8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(n == MAP_IMAGE_ENTITY_LAYER_TYPE_TELE && !IsValidTeleTile((int)TileIndex))
|
||||||
|
ValidTile = false;
|
||||||
|
else if(n == MAP_IMAGE_ENTITY_LAYER_TYPE_TUNE && !IsValidTuneTile((int)TileIndex))
|
||||||
|
ValidTile = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if((EntitiesModType == MAP_IMAGE_MOD_TYPE_RACE) && IsCreditsTile((int)TileIndex))
|
||||||
|
{
|
||||||
|
ValidTile = false;
|
||||||
|
}
|
||||||
|
else if((EntitiesModType == MAP_IMAGE_MOD_TYPE_FNG) && IsCreditsTile((int)TileIndex))
|
||||||
|
{
|
||||||
|
ValidTile = false;
|
||||||
|
}
|
||||||
|
else if((EntitiesModType == MAP_IMAGE_MOD_TYPE_VANILLA) && IsCreditsTile((int)TileIndex))
|
||||||
|
{
|
||||||
|
ValidTile = false;
|
||||||
|
}
|
||||||
|
/*else if((EntitiesModType == MAP_IMAGE_MOD_TYPE_RACE_BLOCKWORLD) && ...)
|
||||||
|
{
|
||||||
|
ValidTile = false;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
int X = TileIndex % 16;
|
||||||
|
int Y = TileIndex / 16;
|
||||||
|
|
||||||
|
int CopyWidth = ImgInfo.m_Width / 16;
|
||||||
|
int CopyHeight = ImgInfo.m_Height / 16;
|
||||||
|
if(ValidTile)
|
||||||
|
{
|
||||||
|
Graphics()->CopyTextureBufferSub(pBuildImgData, pTmpImgData, ImgInfo.m_Width, ImgInfo.m_Height, ColorChannelCount, X * CopyWidth, Y * CopyHeight, CopyWidth, CopyHeight);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_EntitiesTextures[EntitiesModType][n] = Graphics()->LoadTextureRaw(ImgInfo.m_Width, ImgInfo.m_Height, ImgInfo.m_Format, pBuildImgData, ImgInfo.m_Format, TextureLoadFlag, aPath);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(m_TransparentTexture == -1)
|
||||||
|
{
|
||||||
|
// set everything transparent
|
||||||
|
mem_zero(pBuildImgData, BuildImageSize);
|
||||||
|
|
||||||
|
m_TransparentTexture = Graphics()->LoadTextureRaw(ImgInfo.m_Width, ImgInfo.m_Height, ImgInfo.m_Format, pBuildImgData, ImgInfo.m_Format, TextureLoadFlag, aPath);
|
||||||
|
}
|
||||||
|
m_EntitiesTextures[EntitiesModType][n] = m_TransparentTexture;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
free(pBuildImgData);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return m_EntitiesTextures;
|
|
||||||
|
return m_EntitiesTextures[EntitiesModType][EntityLayerType];
|
||||||
}
|
}
|
||||||
|
|
||||||
IGraphics::CTextureHandle CMapImages::GetSpeedupArrow()
|
IGraphics::CTextureHandle CMapImages::GetSpeedupArrow()
|
||||||
|
|
|
@ -4,6 +4,31 @@
|
||||||
#define GAME_CLIENT_COMPONENTS_MAPIMAGES_H
|
#define GAME_CLIENT_COMPONENTS_MAPIMAGES_H
|
||||||
#include <game/client/component.h>
|
#include <game/client/component.h>
|
||||||
|
|
||||||
|
enum EMapImageEntityLayerType
|
||||||
|
{
|
||||||
|
MAP_IMAGE_ENTITY_LAYER_TYPE_GAME = 0,
|
||||||
|
MAP_IMAGE_ENTITY_LAYER_TYPE_FRONT,
|
||||||
|
MAP_IMAGE_ENTITY_LAYER_TYPE_SPEEDUP,
|
||||||
|
MAP_IMAGE_ENTITY_LAYER_TYPE_SWITCH,
|
||||||
|
MAP_IMAGE_ENTITY_LAYER_TYPE_TELE,
|
||||||
|
MAP_IMAGE_ENTITY_LAYER_TYPE_TUNE,
|
||||||
|
|
||||||
|
MAP_IMAGE_ENTITY_LAYER_TYPE_COUNT,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum EMapImageModType
|
||||||
|
{
|
||||||
|
MAP_IMAGE_MOD_TYPE_UNKNOWN = 0,
|
||||||
|
MAP_IMAGE_MOD_TYPE_DDNET,
|
||||||
|
MAP_IMAGE_MOD_TYPE_DDRACE,
|
||||||
|
MAP_IMAGE_MOD_TYPE_RACE,
|
||||||
|
MAP_IMAGE_MOD_TYPE_BLOCKWORLDS,
|
||||||
|
MAP_IMAGE_MOD_TYPE_FNG,
|
||||||
|
MAP_IMAGE_MOD_TYPE_VANILLA,
|
||||||
|
|
||||||
|
MAP_IMAGE_MOD_TYPE_COUNT,
|
||||||
|
};
|
||||||
|
|
||||||
class CMapImages : public CComponent
|
class CMapImages : public CComponent
|
||||||
{
|
{
|
||||||
friend class CBackground;
|
friend class CBackground;
|
||||||
|
@ -12,7 +37,12 @@ class CMapImages : public CComponent
|
||||||
int m_aTextureUsedByTileOrQuadLayerFlag[64]; // 0: nothing, 1(as flag): tile layer, 2(as flag): quad layer
|
int m_aTextureUsedByTileOrQuadLayerFlag[64]; // 0: nothing, 1(as flag): tile layer, 2(as flag): quad layer
|
||||||
int m_Count;
|
int m_Count;
|
||||||
|
|
||||||
const char *m_pEntitiesGameType;
|
bool HasFrontLayer();
|
||||||
|
bool HasSpeedupLayer();
|
||||||
|
bool HasSwitchLayer();
|
||||||
|
bool HasTeleLayer();
|
||||||
|
bool HasTuneLayer();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CMapImages();
|
CMapImages();
|
||||||
CMapImages(int ImageSize);
|
CMapImages(int ImageSize);
|
||||||
|
@ -26,9 +56,9 @@ public:
|
||||||
void LoadBackground(class CLayers *pLayers, class IMap *pMap);
|
void LoadBackground(class CLayers *pLayers, class IMap *pMap);
|
||||||
|
|
||||||
// DDRace
|
// DDRace
|
||||||
IGraphics::CTextureHandle GetEntities();
|
IGraphics::CTextureHandle GetEntities(EMapImageEntityLayerType EntityLayerType);
|
||||||
IGraphics::CTextureHandle GetSpeedupArrow();
|
IGraphics::CTextureHandle GetSpeedupArrow();
|
||||||
|
|
||||||
IGraphics::CTextureHandle GetOverlayBottom();
|
IGraphics::CTextureHandle GetOverlayBottom();
|
||||||
IGraphics::CTextureHandle GetOverlayTop();
|
IGraphics::CTextureHandle GetOverlayTop();
|
||||||
IGraphics::CTextureHandle GetOverlayCenter();
|
IGraphics::CTextureHandle GetOverlayCenter();
|
||||||
|
@ -37,15 +67,16 @@ public:
|
||||||
int GetTextureScale();
|
int GetTextureScale();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_EntitiesIsLoaded;
|
bool m_EntitiesIsLoaded[MAP_IMAGE_MOD_TYPE_COUNT];
|
||||||
bool m_SpeedupArrowIsLoaded;
|
bool m_SpeedupArrowIsLoaded;
|
||||||
IGraphics::CTextureHandle m_EntitiesTextures;
|
IGraphics::CTextureHandle m_EntitiesTextures[MAP_IMAGE_MOD_TYPE_COUNT][MAP_IMAGE_ENTITY_LAYER_TYPE_COUNT];
|
||||||
IGraphics::CTextureHandle m_SpeedupArrowTexture;
|
IGraphics::CTextureHandle m_SpeedupArrowTexture;
|
||||||
IGraphics::CTextureHandle m_OverlayBottomTexture;
|
IGraphics::CTextureHandle m_OverlayBottomTexture;
|
||||||
IGraphics::CTextureHandle m_OverlayTopTexture;
|
IGraphics::CTextureHandle m_OverlayTopTexture;
|
||||||
IGraphics::CTextureHandle m_OverlayCenterTexture;
|
IGraphics::CTextureHandle m_OverlayCenterTexture;
|
||||||
|
IGraphics::CTextureHandle m_TransparentTexture;
|
||||||
int m_TextureScale;
|
int m_TextureScale;
|
||||||
|
|
||||||
void InitOverlayTextures();
|
void InitOverlayTextures();
|
||||||
IGraphics::CTextureHandle UploadEntityLayerText(int TextureSize, int MaxWidth, int YOffset);
|
IGraphics::CTextureHandle UploadEntityLayerText(int TextureSize, int MaxWidth, int YOffset);
|
||||||
void UpdateEntityLayerText(void* pTexBuffer, int ImageColorChannelCount, int TexWidth, int TexHeight, int TextureSize, int MaxWidth, int YOffset, int NumbersPower, int MaxNumber = -1);
|
void UpdateEntityLayerText(void* pTexBuffer, int ImageColorChannelCount, int TexWidth, int TexHeight, int TextureSize, int MaxWidth, int YOffset, int NumbersPower, int MaxNumber = -1);
|
||||||
|
|
|
@ -587,25 +587,19 @@ void CMapLayers::OnMapLoad()
|
||||||
{
|
{
|
||||||
if(IsGameLayer)
|
if(IsGameLayer)
|
||||||
{
|
{
|
||||||
Index = ((CTile*)pTiles)[y*pTMap->m_Width+x].m_Index;
|
Index = ((CTile *)pTiles)[y * pTMap->m_Width + x].m_Index;
|
||||||
Flags = ((CTile*)pTiles)[y*pTMap->m_Width+x].m_Flags;
|
Flags = ((CTile *)pTiles)[y * pTMap->m_Width + x].m_Flags;
|
||||||
if(!GameClient()->m_GameInfo.m_DontMaskEntities && !IsValidGameTile(Index))
|
|
||||||
Index = 0;
|
|
||||||
}
|
}
|
||||||
if(IsFrontLayer)
|
if(IsFrontLayer)
|
||||||
{
|
{
|
||||||
Index = ((CTile*)pTiles)[y*pTMap->m_Width+x].m_Index;
|
Index = ((CTile *)pTiles)[y * pTMap->m_Width + x].m_Index;
|
||||||
Flags = ((CTile*)pTiles)[y*pTMap->m_Width+x].m_Flags;
|
Flags = ((CTile *)pTiles)[y * pTMap->m_Width + x].m_Flags;
|
||||||
if(!GameClient()->m_GameInfo.m_DontMaskEntities && !IsValidFrontTile(Index))
|
|
||||||
Index = 0;
|
|
||||||
}
|
}
|
||||||
if(IsSwitchLayer)
|
if(IsSwitchLayer)
|
||||||
{
|
{
|
||||||
Flags = 0;
|
Flags = 0;
|
||||||
Index = ((CSwitchTile*)pTiles)[y*pTMap->m_Width+x].m_Type;
|
Index = ((CSwitchTile *)pTiles)[y * pTMap->m_Width + x].m_Type;
|
||||||
if(!IsValidSwitchTile(Index))
|
if(CurOverlay == 0)
|
||||||
Index = 0;
|
|
||||||
else if(CurOverlay == 0)
|
|
||||||
{
|
{
|
||||||
Flags = ((CSwitchTile*)pTiles)[y*pTMap->m_Width+x].m_Flags;
|
Flags = ((CSwitchTile*)pTiles)[y*pTMap->m_Width+x].m_Flags;
|
||||||
if(Index == TILE_SWITCHTIMEDOPEN) Index = 8;
|
if(Index == TILE_SWITCHTIMEDOPEN) Index = 8;
|
||||||
|
@ -619,9 +613,7 @@ void CMapLayers::OnMapLoad()
|
||||||
{
|
{
|
||||||
Index = ((CTeleTile*)pTiles)[y*pTMap->m_Width+x].m_Type;
|
Index = ((CTeleTile*)pTiles)[y*pTMap->m_Width+x].m_Type;
|
||||||
Flags = 0;
|
Flags = 0;
|
||||||
if(!IsValidTeleTile(Index))
|
if(CurOverlay == 1)
|
||||||
Index = 0;
|
|
||||||
else if(CurOverlay == 1)
|
|
||||||
{
|
{
|
||||||
if(Index != TILE_TELECHECKIN && Index != TILE_TELECHECKINEVIL)
|
if(Index != TILE_TELECHECKIN && Index != TILE_TELECHECKINEVIL)
|
||||||
Index = ((CTeleTile*)pTiles)[y*pTMap->m_Width+x].m_Number;
|
Index = ((CTeleTile*)pTiles)[y*pTMap->m_Width+x].m_Number;
|
||||||
|
@ -632,8 +624,8 @@ void CMapLayers::OnMapLoad()
|
||||||
{
|
{
|
||||||
Index = ((CSpeedupTile*)pTiles)[y*pTMap->m_Width+x].m_Type;
|
Index = ((CSpeedupTile*)pTiles)[y*pTMap->m_Width+x].m_Type;
|
||||||
Flags = 0;
|
Flags = 0;
|
||||||
AngleRotate = ((CSpeedupTile*)pTiles)[y*pTMap->m_Width + x].m_Angle;
|
AngleRotate = ((CSpeedupTile *)pTiles)[y * pTMap->m_Width + x].m_Angle;
|
||||||
if(!IsValidSpeedupTile(Index) || ((CSpeedupTile*)pTiles)[y*pTMap->m_Width+x].m_Force == 0)
|
if(((CSpeedupTile *)pTiles)[y * pTMap->m_Width + x].m_Force == 0)
|
||||||
Index = 0;
|
Index = 0;
|
||||||
else if(CurOverlay == 1)
|
else if(CurOverlay == 1)
|
||||||
Index = ((CSpeedupTile*)pTiles)[y*pTMap->m_Width+x].m_Force;
|
Index = ((CSpeedupTile*)pTiles)[y*pTMap->m_Width+x].m_Force;
|
||||||
|
@ -642,9 +634,7 @@ void CMapLayers::OnMapLoad()
|
||||||
}
|
}
|
||||||
if(IsTuneLayer)
|
if(IsTuneLayer)
|
||||||
{
|
{
|
||||||
Index = ((CTuneTile*)pTiles)[y*pTMap->m_Width+x].m_Type;
|
Index = ((CTuneTile *)pTiles)[y * pTMap->m_Width + x].m_Type;
|
||||||
if(!IsValidTuneTile(Index))
|
|
||||||
Index = 0;
|
|
||||||
Flags = 0;
|
Flags = 0;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
|
@ -1684,7 +1674,7 @@ void CMapLayers::OnRender()
|
||||||
if(!IsGameLayer)
|
if(!IsGameLayer)
|
||||||
Graphics()->TextureClear();
|
Graphics()->TextureClear();
|
||||||
else
|
else
|
||||||
Graphics()->TextureSet(m_pImages->GetEntities());
|
Graphics()->TextureSet(m_pImages->GetEntities(MAP_IMAGE_ENTITY_LAYER_TYPE_GAME));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Graphics()->TextureSet(m_pImages->Get(pTMap->m_Image));
|
Graphics()->TextureSet(m_pImages->Get(pTMap->m_Image));
|
||||||
|
@ -1784,7 +1774,7 @@ void CMapLayers::OnRender()
|
||||||
else if(Render && g_Config.m_ClOverlayEntities && IsFrontLayer)
|
else if(Render && g_Config.m_ClOverlayEntities && IsFrontLayer)
|
||||||
{
|
{
|
||||||
CMapItemLayerTilemap *pTMap = (CMapItemLayerTilemap *)pLayer;
|
CMapItemLayerTilemap *pTMap = (CMapItemLayerTilemap *)pLayer;
|
||||||
Graphics()->TextureSet(m_pImages->GetEntities());
|
Graphics()->TextureSet(m_pImages->GetEntities(MAP_IMAGE_ENTITY_LAYER_TYPE_FRONT));
|
||||||
|
|
||||||
CTile *pFrontTiles = (CTile *)m_pLayers->Map()->GetData(pTMap->m_Front);
|
CTile *pFrontTiles = (CTile *)m_pLayers->Map()->GetData(pTMap->m_Front);
|
||||||
unsigned int Size = m_pLayers->Map()->GetDataSize(pTMap->m_Front);
|
unsigned int Size = m_pLayers->Map()->GetDataSize(pTMap->m_Front);
|
||||||
|
@ -1811,7 +1801,7 @@ void CMapLayers::OnRender()
|
||||||
else if(Render && g_Config.m_ClOverlayEntities && IsSwitchLayer)
|
else if(Render && g_Config.m_ClOverlayEntities && IsSwitchLayer)
|
||||||
{
|
{
|
||||||
CMapItemLayerTilemap *pTMap = (CMapItemLayerTilemap *)pLayer;
|
CMapItemLayerTilemap *pTMap = (CMapItemLayerTilemap *)pLayer;
|
||||||
Graphics()->TextureSet(m_pImages->GetEntities());
|
Graphics()->TextureSet(m_pImages->GetEntities(MAP_IMAGE_ENTITY_LAYER_TYPE_SWITCH));
|
||||||
|
|
||||||
CSwitchTile *pSwitchTiles = (CSwitchTile *)m_pLayers->Map()->GetData(pTMap->m_Switch);
|
CSwitchTile *pSwitchTiles = (CSwitchTile *)m_pLayers->Map()->GetData(pTMap->m_Switch);
|
||||||
unsigned int Size = m_pLayers->Map()->GetDataSize(pTMap->m_Switch);
|
unsigned int Size = m_pLayers->Map()->GetDataSize(pTMap->m_Switch);
|
||||||
|
@ -1844,7 +1834,7 @@ void CMapLayers::OnRender()
|
||||||
else if(Render && g_Config.m_ClOverlayEntities && IsTeleLayer)
|
else if(Render && g_Config.m_ClOverlayEntities && IsTeleLayer)
|
||||||
{
|
{
|
||||||
CMapItemLayerTilemap *pTMap = (CMapItemLayerTilemap *)pLayer;
|
CMapItemLayerTilemap *pTMap = (CMapItemLayerTilemap *)pLayer;
|
||||||
Graphics()->TextureSet(m_pImages->GetEntities());
|
Graphics()->TextureSet(m_pImages->GetEntities(MAP_IMAGE_ENTITY_LAYER_TYPE_TELE));
|
||||||
|
|
||||||
CTeleTile *pTeleTiles = (CTeleTile *)m_pLayers->Map()->GetData(pTMap->m_Tele);
|
CTeleTile *pTeleTiles = (CTeleTile *)m_pLayers->Map()->GetData(pTMap->m_Tele);
|
||||||
unsigned int Size = m_pLayers->Map()->GetDataSize(pTMap->m_Tele);
|
unsigned int Size = m_pLayers->Map()->GetDataSize(pTMap->m_Tele);
|
||||||
|
@ -1875,7 +1865,7 @@ void CMapLayers::OnRender()
|
||||||
else if(Render && g_Config.m_ClOverlayEntities && IsSpeedupLayer)
|
else if(Render && g_Config.m_ClOverlayEntities && IsSpeedupLayer)
|
||||||
{
|
{
|
||||||
CMapItemLayerTilemap *pTMap = (CMapItemLayerTilemap *)pLayer;
|
CMapItemLayerTilemap *pTMap = (CMapItemLayerTilemap *)pLayer;
|
||||||
Graphics()->TextureSet(m_pImages->GetEntities());
|
Graphics()->TextureSet(m_pImages->GetEntities(MAP_IMAGE_ENTITY_LAYER_TYPE_SPEEDUP));
|
||||||
|
|
||||||
CSpeedupTile *pSpeedupTiles = (CSpeedupTile *)m_pLayers->Map()->GetData(pTMap->m_Speedup);
|
CSpeedupTile *pSpeedupTiles = (CSpeedupTile *)m_pLayers->Map()->GetData(pTMap->m_Speedup);
|
||||||
unsigned int Size = m_pLayers->Map()->GetDataSize(pTMap->m_Speedup);
|
unsigned int Size = m_pLayers->Map()->GetDataSize(pTMap->m_Speedup);
|
||||||
|
@ -1913,7 +1903,7 @@ void CMapLayers::OnRender()
|
||||||
else if(Render && g_Config.m_ClOverlayEntities && IsTuneLayer)
|
else if(Render && g_Config.m_ClOverlayEntities && IsTuneLayer)
|
||||||
{
|
{
|
||||||
CMapItemLayerTilemap *pTMap = (CMapItemLayerTilemap *)pLayer;
|
CMapItemLayerTilemap *pTMap = (CMapItemLayerTilemap *)pLayer;
|
||||||
Graphics()->TextureSet(m_pImages->GetEntities());
|
Graphics()->TextureSet(m_pImages->GetEntities(MAP_IMAGE_ENTITY_LAYER_TYPE_TUNE));
|
||||||
|
|
||||||
CTuneTile *pTuneTiles = (CTuneTile *)m_pLayers->Map()->GetData(pTMap->m_Tune);
|
CTuneTile *pTuneTiles = (CTuneTile *)m_pLayers->Map()->GetData(pTMap->m_Tune);
|
||||||
unsigned int Size = m_pLayers->Map()->GetDataSize(pTMap->m_Tune);
|
unsigned int Size = m_pLayers->Map()->GetDataSize(pTMap->m_Tune);
|
||||||
|
|
|
@ -196,7 +196,7 @@ const CSkins::CSkin *CSkins::Get(int Index)
|
||||||
return &m_aSkins[Index % m_aSkins.size()];
|
return &m_aSkins[Index % m_aSkins.size()];
|
||||||
}
|
}
|
||||||
|
|
||||||
int CSkins::Find(const char *pName) const
|
int CSkins::Find(const char *pName)
|
||||||
{
|
{
|
||||||
const char *pSkinPrefix = m_EventSkinPrefix[0] ? m_EventSkinPrefix : g_Config.m_ClSkinPrefix;
|
const char *pSkinPrefix = m_EventSkinPrefix[0] ? m_EventSkinPrefix : g_Config.m_ClSkinPrefix;
|
||||||
if(g_Config.m_ClVanillaSkinsOnly && !IsVanillaSkin(pName))
|
if(g_Config.m_ClVanillaSkinsOnly && !IsVanillaSkin(pName))
|
||||||
|
@ -217,14 +217,11 @@ int CSkins::Find(const char *pName) const
|
||||||
return FindImpl(pName);
|
return FindImpl(pName);
|
||||||
}
|
}
|
||||||
|
|
||||||
int CSkins::FindImpl(const char *pName) const
|
int CSkins::FindImpl(const char *pName)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < m_aSkins.size(); i++)
|
auto r = ::find_binary(m_aSkins.all(), pName);
|
||||||
{
|
if(r.empty())
|
||||||
if(str_comp(m_aSkins[i].m_aName, pName) == 0)
|
return -1;
|
||||||
{
|
|
||||||
return i;
|
return &r.front() - m_aSkins.base_ptr();
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,19 +20,22 @@ public:
|
||||||
ColorRGBA m_BloodColor;
|
ColorRGBA m_BloodColor;
|
||||||
|
|
||||||
bool operator<(const CSkin &Other) { return str_comp(m_aName, Other.m_aName) < 0; }
|
bool operator<(const CSkin &Other) { return str_comp(m_aName, Other.m_aName) < 0; }
|
||||||
|
|
||||||
|
bool operator<(const char *pOther) { return str_comp(m_aName, pOther) < 0; }
|
||||||
|
bool operator==(const char *pOther) { return !str_comp(m_aName, pOther); }
|
||||||
};
|
};
|
||||||
|
|
||||||
void OnInit();
|
void OnInit();
|
||||||
|
|
||||||
int Num();
|
int Num();
|
||||||
const CSkin *Get(int Index);
|
const CSkin *Get(int Index);
|
||||||
int Find(const char *pName) const;
|
int Find(const char *pName);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
sorted_array<CSkin> m_aSkins;
|
sorted_array<CSkin> m_aSkins;
|
||||||
char m_EventSkinPrefix[100];
|
char m_EventSkinPrefix[100];
|
||||||
|
|
||||||
int FindImpl(const char *pName) const;
|
int FindImpl(const char *pName);
|
||||||
static int SkinScan(const char *pName, int IsDir, int DirType, void *pUser);
|
static int SkinScan(const char *pName, int IsDir, int DirType, void *pUser);
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1548,18 +1548,20 @@ void CLayerSpeedup::BrushDraw(CLayer *pBrush, float wx, float wy)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_pSpeedupTile[fy*m_Width+fx].m_Force = 0;
|
m_pSpeedupTile[fy * m_Width + fx].m_Force = 0;
|
||||||
m_pSpeedupTile[fy*m_Width+fx].m_MaxSpeed = 0;
|
m_pSpeedupTile[fy * m_Width + fx].m_MaxSpeed = 0;
|
||||||
m_pSpeedupTile[fy*m_Width+fx].m_Angle = 0;
|
m_pSpeedupTile[fy * m_Width + fx].m_Angle = 0;
|
||||||
m_pTiles[fy*m_Width+fx].m_Index = 0;
|
m_pSpeedupTile[fy * m_Width + fx].m_Type = 0;
|
||||||
|
m_pTiles[fy * m_Width + fx].m_Index = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_pSpeedupTile[fy*m_Width+fx].m_Force = 0;
|
m_pSpeedupTile[fy * m_Width + fx].m_Force = 0;
|
||||||
m_pSpeedupTile[fy*m_Width+fx].m_MaxSpeed = 0;
|
m_pSpeedupTile[fy * m_Width + fx].m_MaxSpeed = 0;
|
||||||
m_pSpeedupTile[fy*m_Width+fx].m_Angle = 0;
|
m_pSpeedupTile[fy * m_Width + fx].m_Angle = 0;
|
||||||
m_pTiles[fy*m_Width+fx].m_Index = 0;
|
m_pSpeedupTile[fy * m_Width + fx].m_Type = 0;
|
||||||
|
m_pTiles[fy * m_Width + fx].m_Index = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FlagModified(sx, sy, l->m_Width, l->m_Height);
|
FlagModified(sx, sy, l->m_Width, l->m_Height);
|
||||||
|
|
|
@ -111,3 +111,17 @@ bool IsRotatableTile(int Index)
|
||||||
|| Index - ENTITY_OFFSET == ENTITY_CRAZY_SHOTGUN
|
|| Index - ENTITY_OFFSET == ENTITY_CRAZY_SHOTGUN
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsCreditsTile(int TileIndex)
|
||||||
|
{
|
||||||
|
return (
|
||||||
|
(TILE_CREDITS_1 == TileIndex)
|
||||||
|
|| (TILE_CREDITS_2 == TileIndex)
|
||||||
|
|| (TILE_CREDITS_3 == TileIndex)
|
||||||
|
|| (TILE_CREDITS_4 == TileIndex)
|
||||||
|
|| (TILE_CREDITS_5 == TileIndex)
|
||||||
|
|| (TILE_CREDITS_6 == TileIndex)
|
||||||
|
|| (TILE_CREDITS_7 == TileIndex)
|
||||||
|
|| (TILE_CREDITS_8 == TileIndex)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
|
@ -484,5 +484,6 @@ bool IsValidSwitchTile(int Index);
|
||||||
bool IsValidTuneTile(int Index);
|
bool IsValidTuneTile(int Index);
|
||||||
bool IsValidEntity(int Index);
|
bool IsValidEntity(int Index);
|
||||||
bool IsRotatableTile(int Index);
|
bool IsRotatableTile(int Index);
|
||||||
|
bool IsCreditsTile(int TileIndex);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#ifndef GAME_SERVER_PRNG_H
|
#ifndef GAME_PRNG_H
|
||||||
#define GAME_SERVER_PRNG_H
|
#define GAME_PRNG_H
|
||||||
|
|
||||||
#include <base/system.h>
|
#include <base/system.h>
|
||||||
|
|
||||||
|
@ -29,4 +29,4 @@ private:
|
||||||
uint64 m_Increment;
|
uint64 m_Increment;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GAME_SERVER_PRNG_H
|
#endif // GAME_PRNG_H
|
||||||
|
|
|
@ -671,7 +671,8 @@ void CGameContext::ConSave(IConsole::IResult *pResult, void *pUserData)
|
||||||
str_copy(aCountry, g_Config.m_SvSqlServerName, sizeof(aCountry));
|
str_copy(aCountry, g_Config.m_SvSqlServerName, sizeof(aCountry));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(str_in_list(g_Config.m_SvSqlValidServerNames, ",", aCountry))
|
if(str_comp(aCountry, g_Config.m_SvSqlServerName) == 0 ||
|
||||||
|
str_in_list(g_Config.m_SvSqlValidServerNames, ",", aCountry))
|
||||||
{
|
{
|
||||||
pSelf->Score()->SaveTeam(pResult->m_ClientID, pCode, aCountry);
|
pSelf->Score()->SaveTeam(pResult->m_ClientID, pCode, aCountry);
|
||||||
}
|
}
|
||||||
|
|
|
@ -508,33 +508,34 @@ bool CScore::SaveScoreThread(IDbConnection *pSqlServer, const ISqlData *pGameDat
|
||||||
|
|
||||||
// save score. Can't fail, because no UNIQUE/PRIMARY KEY constrain is defined.
|
// save score. Can't fail, because no UNIQUE/PRIMARY KEY constrain is defined.
|
||||||
str_format(aBuf, sizeof(aBuf),
|
str_format(aBuf, sizeof(aBuf),
|
||||||
"%s INTO %s_race("
|
"%s INTO %s_race("
|
||||||
"Map, Name, Timestamp, Time, Server, "
|
" Map, Name, Timestamp, Time, Server, "
|
||||||
"cp1, cp2, cp3, cp4, cp5, cp6, cp7, cp8, cp9, cp10, cp11, cp12, cp13, "
|
" cp1, cp2, cp3, cp4, cp5, cp6, cp7, cp8, cp9, cp10, cp11, cp12, cp13, "
|
||||||
"cp14, cp15, cp16, cp17, cp18, cp19, cp20, cp21, cp22, cp23, cp24, cp25, "
|
" cp14, cp15, cp16, cp17, cp18, cp19, cp20, cp21, cp22, cp23, cp24, cp25, "
|
||||||
"GameID, DDNet7) "
|
" GameID, DDNet7) "
|
||||||
"VALUES (?, ?, %s, %.2f, ?, "
|
"VALUES (?, ?, %s, %.2f, ?, "
|
||||||
"%.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, "
|
" %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, "
|
||||||
"%.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, "
|
" %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, "
|
||||||
"%.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, "
|
" %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, "
|
||||||
"?, false);",
|
" ?, false);",
|
||||||
pSqlServer->GetInsertIgnore(), pSqlServer->GetPrefix(),
|
pSqlServer->InsertIgnore(), pSqlServer->GetPrefix(),
|
||||||
pSqlServer->InsertTimestampAsUtc(), pData->m_Time,
|
pSqlServer->InsertTimestampAsUtc(), pData->m_Time,
|
||||||
pData->m_aCpCurrent[0], pData->m_aCpCurrent[1], pData->m_aCpCurrent[2],
|
pData->m_aCpCurrent[0], pData->m_aCpCurrent[1], pData->m_aCpCurrent[2],
|
||||||
pData->m_aCpCurrent[3], pData->m_aCpCurrent[4], pData->m_aCpCurrent[5],
|
pData->m_aCpCurrent[3], pData->m_aCpCurrent[4], pData->m_aCpCurrent[5],
|
||||||
pData->m_aCpCurrent[6], pData->m_aCpCurrent[7], pData->m_aCpCurrent[8],
|
pData->m_aCpCurrent[6], pData->m_aCpCurrent[7], pData->m_aCpCurrent[8],
|
||||||
pData->m_aCpCurrent[9], pData->m_aCpCurrent[10], pData->m_aCpCurrent[11],
|
pData->m_aCpCurrent[9], pData->m_aCpCurrent[10], pData->m_aCpCurrent[11],
|
||||||
pData->m_aCpCurrent[12], pData->m_aCpCurrent[13], pData->m_aCpCurrent[14],
|
pData->m_aCpCurrent[12], pData->m_aCpCurrent[13], pData->m_aCpCurrent[14],
|
||||||
pData->m_aCpCurrent[15], pData->m_aCpCurrent[16], pData->m_aCpCurrent[17],
|
pData->m_aCpCurrent[15], pData->m_aCpCurrent[16], pData->m_aCpCurrent[17],
|
||||||
pData->m_aCpCurrent[18], pData->m_aCpCurrent[19], pData->m_aCpCurrent[20],
|
pData->m_aCpCurrent[18], pData->m_aCpCurrent[19], pData->m_aCpCurrent[20],
|
||||||
pData->m_aCpCurrent[21], pData->m_aCpCurrent[22], pData->m_aCpCurrent[23],
|
pData->m_aCpCurrent[21], pData->m_aCpCurrent[22], pData->m_aCpCurrent[23],
|
||||||
pData->m_aCpCurrent[24]);
|
pData->m_aCpCurrent[24]);
|
||||||
pSqlServer->PrepareStatement(aBuf);
|
pSqlServer->PrepareStatement(aBuf);
|
||||||
pSqlServer->BindString(1, pData->m_Map);
|
pSqlServer->BindString(1, pData->m_Map);
|
||||||
pSqlServer->BindString(2, pData->m_Name);
|
pSqlServer->BindString(2, pData->m_Name);
|
||||||
pSqlServer->BindString(3, pData->m_aTimestamp);
|
pSqlServer->BindString(3, pData->m_aTimestamp);
|
||||||
pSqlServer->BindString(4, g_Config.m_SvSqlServerName);
|
pSqlServer->BindString(4, g_Config.m_SvSqlServerName);
|
||||||
pSqlServer->BindString(5, pData->m_GameUuid);
|
pSqlServer->BindString(5, pData->m_GameUuid);
|
||||||
|
pSqlServer->Print();
|
||||||
pSqlServer->Step();
|
pSqlServer->Step();
|
||||||
|
|
||||||
pData->m_pResult->m_Done = true;
|
pData->m_pResult->m_Done = true;
|
||||||
|
@ -617,6 +618,7 @@ bool CScore::SaveTeamScoreThread(IDbConnection *pSqlServer, const ISqlData *pGam
|
||||||
pSqlServer->BindString(1, pData->m_aTimestamp);
|
pSqlServer->BindString(1, pData->m_aTimestamp);
|
||||||
pSqlServer->BindString(2, pData->m_GameUuid);
|
pSqlServer->BindString(2, pData->m_GameUuid);
|
||||||
pSqlServer->BindBlob(3, Teamrank.m_TeamID.m_aData, sizeof(Teamrank.m_TeamID.m_aData));
|
pSqlServer->BindBlob(3, Teamrank.m_TeamID.m_aData, sizeof(Teamrank.m_TeamID.m_aData));
|
||||||
|
pSqlServer->Print();
|
||||||
pSqlServer->Step();
|
pSqlServer->Step();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -627,16 +629,17 @@ bool CScore::SaveTeamScoreThread(IDbConnection *pSqlServer, const ISqlData *pGam
|
||||||
{
|
{
|
||||||
// if no entry found... create a new one
|
// if no entry found... create a new one
|
||||||
str_format(aBuf, sizeof(aBuf),
|
str_format(aBuf, sizeof(aBuf),
|
||||||
"%s INTO %s_teamrace(Map, Name, Timestamp, Time, ID, GameID, DDNet7) "
|
"%s INTO %s_teamrace(Map, Name, Timestamp, Time, ID, GameID, DDNet7) "
|
||||||
"VALUES (?, ?, %s, %.2f, ?, ?, false);",
|
"VALUES (?, ?, %s, %.2f, ?, ?, false);",
|
||||||
pSqlServer->GetInsertIgnore(), pSqlServer->GetPrefix(),
|
pSqlServer->InsertIgnore(), pSqlServer->GetPrefix(),
|
||||||
pSqlServer->InsertTimestampAsUtc(), pData->m_Time);
|
pSqlServer->InsertTimestampAsUtc(), pData->m_Time);
|
||||||
pSqlServer->PrepareStatement(aBuf);
|
pSqlServer->PrepareStatement(aBuf);
|
||||||
pSqlServer->BindString(1, pData->m_Map);
|
pSqlServer->BindString(1, pData->m_Map);
|
||||||
pSqlServer->BindString(2, pData->m_aNames[i]);
|
pSqlServer->BindString(2, pData->m_aNames[i]);
|
||||||
pSqlServer->BindString(3, pData->m_aTimestamp);
|
pSqlServer->BindString(3, pData->m_aTimestamp);
|
||||||
pSqlServer->BindBlob(4, GameID.m_aData, sizeof(GameID.m_aData));
|
pSqlServer->BindBlob(4, GameID.m_aData, sizeof(GameID.m_aData));
|
||||||
pSqlServer->BindString(5, pData->m_GameUuid);
|
pSqlServer->BindString(5, pData->m_GameUuid);
|
||||||
|
pSqlServer->Print();
|
||||||
pSqlServer->Step();
|
pSqlServer->Step();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1315,15 +1318,16 @@ bool CScore::SaveTeamThread(IDbConnection *pSqlServer, const ISqlData *pGameData
|
||||||
if(UseCode)
|
if(UseCode)
|
||||||
{
|
{
|
||||||
str_format(aBuf, sizeof(aBuf),
|
str_format(aBuf, sizeof(aBuf),
|
||||||
"%s INTO %s_saves(Savegame, Map, Code, Timestamp, Server, SaveID, DDNet7) "
|
"%s INTO %s_saves(Savegame, Map, Code, Timestamp, Server, SaveID, DDNet7) "
|
||||||
"VALUES (?, ?, ?, CURRENT_TIMESTAMP, ?, ?, false)",
|
"VALUES (?, ?, ?, CURRENT_TIMESTAMP, ?, ?, false)",
|
||||||
pSqlServer->GetInsertIgnore(), pSqlServer->GetPrefix());
|
pSqlServer->InsertIgnore(), pSqlServer->GetPrefix());
|
||||||
pSqlServer->PrepareStatement(aBuf);
|
pSqlServer->PrepareStatement(aBuf);
|
||||||
pSqlServer->BindString(1, pSaveState);
|
pSqlServer->BindString(1, pSaveState);
|
||||||
pSqlServer->BindString(2, pData->m_Map);
|
pSqlServer->BindString(2, pData->m_Map);
|
||||||
pSqlServer->BindString(3, Code);
|
pSqlServer->BindString(3, Code);
|
||||||
pSqlServer->BindString(4, pData->m_Server);
|
pSqlServer->BindString(4, pData->m_Server);
|
||||||
pSqlServer->BindString(5, aSaveID);
|
pSqlServer->BindString(5, aSaveID);
|
||||||
|
pSqlServer->Print();
|
||||||
pSqlServer->Step();
|
pSqlServer->Step();
|
||||||
|
|
||||||
if(!Failure)
|
if(!Failure)
|
||||||
|
@ -1498,6 +1502,7 @@ bool CScore::LoadTeamThread(IDbConnection *pSqlServer, const ISqlData *pGameData
|
||||||
pSqlServer->PrepareStatement(aBuf);
|
pSqlServer->PrepareStatement(aBuf);
|
||||||
pSqlServer->BindString(1, pData->m_Code);
|
pSqlServer->BindString(1, pData->m_Code);
|
||||||
pSqlServer->BindString(2, pData->m_Map);
|
pSqlServer->BindString(2, pData->m_Map);
|
||||||
|
pSqlServer->Print();
|
||||||
pSqlServer->Step();
|
pSqlServer->Step();
|
||||||
|
|
||||||
pData->m_pResult->m_Status = CScoreSaveResult::LOAD_SUCCESS;
|
pData->m_pResult->m_Status = CScoreSaveResult::LOAD_SUCCESS;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#ifndef STEAMAPI_STEAM_STEAM_API_FLAT_H
|
#ifndef STEAM_STEAM_API_FLAT_H
|
||||||
#define STEAMAPI_STEAM_STEAM_API_FLAT_H
|
#define STEAM_STEAM_API_FLAT_H
|
||||||
|
|
||||||
#include <base/dynamic.h>
|
#include <base/dynamic.h>
|
||||||
|
|
||||||
|
@ -60,4 +60,4 @@ STEAMAPI bool SteamAPI_ISteamFriends_SetRichPresence(ISteamFriends *pSelf, const
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // STEAMAPI_STEAM_API_FLAT_H
|
#endif // STEAM_STEAM_API_FLAT_H
|
||||||
|
|
|
@ -54,7 +54,14 @@ int DilateFile(const char *pFileName)
|
||||||
CPixel *pBuffer[3] = {0,0,0};
|
CPixel *pBuffer[3] = {0,0,0};
|
||||||
|
|
||||||
png_init(0, 0);
|
png_init(0, 0);
|
||||||
png_open_file(&Png, pFileName);
|
int Error = png_open_file(&Png, pFileName);
|
||||||
|
if(Error != PNG_NO_ERROR)
|
||||||
|
{
|
||||||
|
dbg_msg("dilate", "failed to open image file. filename='%s'", pFileName);
|
||||||
|
if(Error != PNG_FILE_ERROR)
|
||||||
|
png_close_file(&Png);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if(Png.color_type != PNG_TRUECOLOR_ALPHA)
|
if(Png.color_type != PNG_TRUECOLOR_ALPHA)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,87 +0,0 @@
|
||||||
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
|
|
||||||
/* If you are missing that file, acquire a complete release at teeworlds.com. */
|
|
||||||
#include <base/math.h>
|
|
||||||
#include <base/system.h>
|
|
||||||
|
|
||||||
#include <pnglite.h>
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
unsigned char r, g, b, a;
|
|
||||||
} CPixel;
|
|
||||||
|
|
||||||
static void TilesetBorderadd(int w, int h, CPixel *pSrc, CPixel *pDest)
|
|
||||||
{
|
|
||||||
int TileW = w/16;
|
|
||||||
int TileH = h/16;
|
|
||||||
|
|
||||||
for(int tx = 0; tx < 16; tx++)
|
|
||||||
{
|
|
||||||
for(int ty = 0; ty < 16; ty++)
|
|
||||||
{
|
|
||||||
for(int x = 0; x < TileW + 4; x++)
|
|
||||||
{
|
|
||||||
for(int y = 0; y < TileH + 4; y++)
|
|
||||||
{
|
|
||||||
int SourceX = tx * TileW + clamp(x - 2, 0, TileW - 1);
|
|
||||||
int SourceY = ty * TileH + clamp(y - 2, 0, TileH - 1);
|
|
||||||
int DestX = tx * (TileW + 4) + x;
|
|
||||||
int DestY = ty * (TileH + 4) + y;
|
|
||||||
|
|
||||||
int SourceI = SourceY * w + SourceX;
|
|
||||||
int DestI = DestY * (w + 16 * 4) + DestX;
|
|
||||||
|
|
||||||
pDest[DestI] = pSrc[SourceI];
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int FixFile(const char *pFileName)
|
|
||||||
{
|
|
||||||
png_t Png;
|
|
||||||
CPixel *pBuffer[2] = {0,0};
|
|
||||||
|
|
||||||
png_init(0, 0);
|
|
||||||
png_open_file(&Png, pFileName);
|
|
||||||
|
|
||||||
if(Png.color_type != PNG_TRUECOLOR_ALPHA)
|
|
||||||
{
|
|
||||||
dbg_msg("tileset_borderadd", "%s: not an RGBA image", pFileName);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int w = Png.width;
|
|
||||||
int h = Png.height;
|
|
||||||
|
|
||||||
pBuffer[0] = (CPixel *)malloc(w * h * sizeof(CPixel));
|
|
||||||
pBuffer[1] = (CPixel *)malloc((w + 16 * 4) * (h + 16 * 4) * sizeof(CPixel));
|
|
||||||
png_get_data(&Png, (unsigned char *)pBuffer[0]);
|
|
||||||
png_close_file(&Png);
|
|
||||||
|
|
||||||
TilesetBorderadd(w, h, pBuffer[0], pBuffer[1]);
|
|
||||||
|
|
||||||
// save here
|
|
||||||
png_open_file_write(&Png, pFileName);
|
|
||||||
png_set_data(&Png, w + 16 * 4, h + 16 * 4, 8, PNG_TRUECOLOR_ALPHA, (unsigned char *)pBuffer[1]);
|
|
||||||
png_close_file(&Png);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, const char **argv)
|
|
||||||
{
|
|
||||||
dbg_logger_stdout();
|
|
||||||
if(argc == 1)
|
|
||||||
{
|
|
||||||
dbg_msg("usage", "%s FILE1 [ FILE2... ]", argv[0]);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(int i = 1; i < argc; i++)
|
|
||||||
FixFile(argv[i]);
|
|
||||||
return 0;
|
|
||||||
}
|
|
|
@ -1,99 +0,0 @@
|
||||||
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
|
|
||||||
/* If you are missing that file, acquire a complete release at teeworlds.com. */
|
|
||||||
#include <base/system.h>
|
|
||||||
|
|
||||||
#include <pnglite.h>
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
unsigned char r, g, b, a;
|
|
||||||
} CPixel;
|
|
||||||
|
|
||||||
static CPixel Sample(int x, int y, int w, int h, CPixel *pData, int Pitch, float u, float v)
|
|
||||||
{
|
|
||||||
x = x + (int)(w*u);
|
|
||||||
y = y + (int)(h*v);
|
|
||||||
return pData[y*Pitch+x];
|
|
||||||
}
|
|
||||||
|
|
||||||
static void TilesetBorderfix(int w, int h, CPixel *pSrc, CPixel *pDest)
|
|
||||||
{
|
|
||||||
int TileW = w/16;
|
|
||||||
int TileH = h/16;
|
|
||||||
|
|
||||||
mem_zero(pDest, sizeof(CPixel)*w*h);
|
|
||||||
|
|
||||||
for(int ty = 0; ty < 16; ty++)
|
|
||||||
{
|
|
||||||
for(int tx = 0; tx < 16; tx++)
|
|
||||||
{
|
|
||||||
for(int y = 0; y < TileH-2; y++)
|
|
||||||
{
|
|
||||||
for(int x = 0; x < TileW-2; x++)
|
|
||||||
{
|
|
||||||
float u = 0.5f/TileW + x/(float)(TileW-2);
|
|
||||||
float v = 0.5f/TileH + y/(float)(TileH-2);
|
|
||||||
int k = (ty*TileH+1+y)*w + tx*TileW+x+1;
|
|
||||||
pDest[k] = Sample(tx*TileW, ty*TileH, TileW, TileH, pSrc, w, u, v);
|
|
||||||
|
|
||||||
if(x == 0) pDest[k-1] = pDest[k];
|
|
||||||
if(x == TileW-2-1) pDest[k+1] = pDest[k];
|
|
||||||
if(y == 0) pDest[k-w] = pDest[k];
|
|
||||||
if(y == TileH-2-1) pDest[k+w] = pDest[k];
|
|
||||||
|
|
||||||
if(x == 0 && y == 0) pDest[k-w-1] = pDest[k];
|
|
||||||
if(x == TileW-2-1 && y == 0) pDest[k-w+1] = pDest[k];
|
|
||||||
if(x == 0 && y == TileH-2-1) pDest[k+w-1] = pDest[k];
|
|
||||||
if(x == TileW-2-1 && y == TileH-2-1) pDest[k+w+1] = pDest[k];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int FixFile(const char *pFileName)
|
|
||||||
{
|
|
||||||
png_t Png;
|
|
||||||
CPixel *pBuffer[2] = {0,0};
|
|
||||||
|
|
||||||
png_init(0, 0);
|
|
||||||
png_open_file(&Png, pFileName);
|
|
||||||
|
|
||||||
if(Png.color_type != PNG_TRUECOLOR_ALPHA)
|
|
||||||
{
|
|
||||||
dbg_msg("tileset_borderfix", "%s: not an RGBA image", pFileName);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int w = Png.width;
|
|
||||||
int h = Png.height;
|
|
||||||
|
|
||||||
pBuffer[0] = (CPixel *)malloc(w * h * sizeof(CPixel));
|
|
||||||
pBuffer[1] = (CPixel *)malloc(w * h * sizeof(CPixel));
|
|
||||||
png_get_data(&Png, (unsigned char *)pBuffer[0]);
|
|
||||||
png_close_file(&Png);
|
|
||||||
|
|
||||||
TilesetBorderfix(w, h, pBuffer[0], pBuffer[1]);
|
|
||||||
|
|
||||||
// save here
|
|
||||||
png_open_file_write(&Png, pFileName);
|
|
||||||
png_set_data(&Png, w, h, 8, PNG_TRUECOLOR_ALPHA, (unsigned char *)pBuffer[1]);
|
|
||||||
png_close_file(&Png);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, const char **argv)
|
|
||||||
{
|
|
||||||
dbg_logger_stdout();
|
|
||||||
if(argc == 1)
|
|
||||||
{
|
|
||||||
dbg_msg("usage", "%s FILE1 [ FILE2... ]", argv[0]);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(int i = 1; i < argc; i++)
|
|
||||||
FixFile(argv[i]);
|
|
||||||
return 0;
|
|
||||||
}
|
|
|
@ -1,87 +0,0 @@
|
||||||
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
|
|
||||||
/* If you are missing that file, acquire a complete release at teeworlds.com. */
|
|
||||||
#include <base/math.h>
|
|
||||||
#include <base/system.h>
|
|
||||||
|
|
||||||
#include <pnglite.h>
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
unsigned char r, g, b, a;
|
|
||||||
} CPixel;
|
|
||||||
|
|
||||||
static void TilesetBorderrem(int w, int h, CPixel *pSrc, CPixel *pDest)
|
|
||||||
{
|
|
||||||
int TileW = w/16;
|
|
||||||
int TileH = h/16;
|
|
||||||
|
|
||||||
for(int tx = 0; tx < 16; tx++)
|
|
||||||
{
|
|
||||||
for(int ty = 0; ty < 16; ty++)
|
|
||||||
{
|
|
||||||
for(int x = 0; x < TileW - 4; x++)
|
|
||||||
{
|
|
||||||
for(int y = 0; y < TileH - 4; y++)
|
|
||||||
{
|
|
||||||
int SourceX = tx * TileW + x + 2;
|
|
||||||
int SourceY = ty * TileH + y + 2;
|
|
||||||
int DestX = tx * (TileW - 4) + x;
|
|
||||||
int DestY = ty * (TileH - 4) + y;
|
|
||||||
|
|
||||||
int SourceI = SourceY * w + SourceX;
|
|
||||||
int DestI = DestY * (w - 16 * 4) + DestX;
|
|
||||||
|
|
||||||
pDest[DestI] = pSrc[SourceI];
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int FixFile(const char *pFileName)
|
|
||||||
{
|
|
||||||
png_t Png;
|
|
||||||
CPixel *pBuffer[2] = {0,0};
|
|
||||||
|
|
||||||
png_init(0, 0);
|
|
||||||
png_open_file(&Png, pFileName);
|
|
||||||
|
|
||||||
if(Png.color_type != PNG_TRUECOLOR_ALPHA)
|
|
||||||
{
|
|
||||||
dbg_msg("tileset_borderrem", "%s: not an RGBA image", pFileName);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int w = Png.width;
|
|
||||||
int h = Png.height;
|
|
||||||
|
|
||||||
pBuffer[0] = (CPixel *)malloc(w * h * sizeof(CPixel));
|
|
||||||
pBuffer[1] = (CPixel *)malloc((w - 16 * 4) * (h - 16 * 4) * sizeof(CPixel));
|
|
||||||
png_get_data(&Png, (unsigned char *)pBuffer[0]);
|
|
||||||
png_close_file(&Png);
|
|
||||||
|
|
||||||
TilesetBorderrem(w, h, pBuffer[0], pBuffer[1]);
|
|
||||||
|
|
||||||
// save here
|
|
||||||
png_open_file_write(&Png, pFileName);
|
|
||||||
png_set_data(&Png, w - 16 * 4, h - 16 * 4, 8, PNG_TRUECOLOR_ALPHA, (unsigned char *)pBuffer[1]);
|
|
||||||
png_close_file(&Png);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, const char **argv)
|
|
||||||
{
|
|
||||||
dbg_logger_stdout();
|
|
||||||
if(argc == 1)
|
|
||||||
{
|
|
||||||
dbg_msg("usage", "%s FILE1 [ FILE2... ]", argv[0]);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(int i = 1; i < argc; i++)
|
|
||||||
FixFile(argv[i]);
|
|
||||||
return 0;
|
|
||||||
}
|
|
|
@ -1,79 +0,0 @@
|
||||||
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
|
|
||||||
/* If you are missing that file, acquire a complete release at teeworlds.com. */
|
|
||||||
#include <base/math.h>
|
|
||||||
#include <base/system.h>
|
|
||||||
|
|
||||||
#include <pnglite.h>
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
unsigned char r, g, b, a;
|
|
||||||
} CPixel;
|
|
||||||
|
|
||||||
static void TilesetBorderset(int w, int h, CPixel *pSrc, CPixel *pDest)
|
|
||||||
{
|
|
||||||
int TileW = w/16;
|
|
||||||
int TileH = h/16;
|
|
||||||
|
|
||||||
for(int tx = 0; tx < 16; tx++)
|
|
||||||
{
|
|
||||||
for(int ty = 0; ty < 16; ty++)
|
|
||||||
{
|
|
||||||
for(int x = 0; x < TileW; x++)
|
|
||||||
{
|
|
||||||
for(int y = 0; y < TileH; y++)
|
|
||||||
{
|
|
||||||
#define TILE_INDEX(tx_, ty_, x_, y_) (((ty_) * TileH + (y_)) * w + (tx_) * TileW + (x_))
|
|
||||||
pDest[TILE_INDEX(tx, ty, x, y)] = pSrc[TILE_INDEX(tx, ty, clamp(x, 2, TileW - 3), clamp(y, 2, TileH - 3))];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int FixFile(const char *pFileName)
|
|
||||||
{
|
|
||||||
png_t Png;
|
|
||||||
CPixel *pBuffer[2] = {0,0};
|
|
||||||
|
|
||||||
png_init(0, 0);
|
|
||||||
png_open_file(&Png, pFileName);
|
|
||||||
|
|
||||||
if(Png.color_type != PNG_TRUECOLOR_ALPHA)
|
|
||||||
{
|
|
||||||
dbg_msg("tileset_borderset", "%s: not an RGBA image", pFileName);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int w = Png.width;
|
|
||||||
int h = Png.height;
|
|
||||||
|
|
||||||
pBuffer[0] = (CPixel *)malloc(w * h * sizeof(CPixel));
|
|
||||||
pBuffer[1] = (CPixel *)malloc(w * h * sizeof(CPixel));
|
|
||||||
png_get_data(&Png, (unsigned char *)pBuffer[0]);
|
|
||||||
png_close_file(&Png);
|
|
||||||
|
|
||||||
TilesetBorderset(w, h, pBuffer[0], pBuffer[1]);
|
|
||||||
|
|
||||||
// save here
|
|
||||||
png_open_file_write(&Png, pFileName);
|
|
||||||
png_set_data(&Png, w, h, 8, PNG_TRUECOLOR_ALPHA, (unsigned char *)pBuffer[1]);
|
|
||||||
png_close_file(&Png);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, const char **argv)
|
|
||||||
{
|
|
||||||
dbg_logger_stdout();
|
|
||||||
if(argc == 1)
|
|
||||||
{
|
|
||||||
dbg_msg("usage", "%s FILE1 [ FILE2... ]", argv[0]);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(int i = 1; i < argc; i++)
|
|
||||||
FixFile(argv[i]);
|
|
||||||
return 0;
|
|
||||||
}
|
|