Skip to content

Commit

Permalink
Use client 'six' data structs for client 'seven' data
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaffeine committed Oct 6, 2023
1 parent 26b4a41 commit b6470e5
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 40 deletions.
14 changes: 2 additions & 12 deletions datasrc/seven/compile.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sys
from .datatypes import EmitDefinition, EmitTypeDeclaration
from .datatypes import EmitDefinition
from . import content # pylint: disable=no-name-in-module
from . import network # pylint: disable=no-name-in-module

Expand Down Expand Up @@ -60,19 +60,9 @@ def main():
if gen_client_content_header or gen_server_content_header:
# print some includes
print('#include <engine/graphics.h>')
print('#include "data_types.h"')
print("namespace client_data7 {")

# emit the type declarations
with open("datasrc/content.py", "rb") as f:
contentlines = f.readlines()
order = []
for line in contentlines:
line = line.strip()
if line[:6] == "class ".encode() and "(Struct)".encode() in line:
order += [line.split()[1].split("(".encode())[0].decode("ascii")]
for name in order:
EmitTypeDeclaration(content.__dict__[name])

# the container pointer
print('extern CDataContainer *g_pData;')

Expand Down
13 changes: 1 addition & 12 deletions src/engine/client/graphics_threaded.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,17 +382,6 @@ IGraphics::CTextureHandle CGraphics_Threaded::LoadSpriteTexture(CImageInfo &From
return LoadSpriteTextureImpl(FromImageInfo, x, y, w, h);
}

IGraphics::CTextureHandle CGraphics_Threaded::LoadSpriteTexture(CImageInfo &FromImageInfo, client_data7::CDataSprite *pSprite)
{
int imggx = FromImageInfo.m_Width / pSprite->m_pSet->m_Gridx;
int imggy = FromImageInfo.m_Height / pSprite->m_pSet->m_Gridy;
int x = pSprite->m_X * imggx;
int y = pSprite->m_Y * imggy;
int w = pSprite->m_W * imggx;
int h = pSprite->m_H * imggy;
return LoadSpriteTextureImpl(FromImageInfo, x, y, w, h);
}

bool CGraphics_Threaded::IsImageSubFullyTransparent(CImageInfo &FromImageInfo, int x, int y, int w, int h)
{
if(FromImageInfo.m_Format == CImageInfo::FORMAT_SINGLE_COMPONENT || FromImageInfo.m_Format == CImageInfo::FORMAT_RGBA)
Expand All @@ -414,7 +403,7 @@ bool CGraphics_Threaded::IsImageSubFullyTransparent(CImageInfo &FromImageInfo, i
return false;
}

bool CGraphics_Threaded::IsSpriteTextureFullyTransparent(CImageInfo &FromImageInfo, client_data7::CDataSprite *pSprite)
bool CGraphics_Threaded::IsSpriteTextureFullyTransparent(CImageInfo &FromImageInfo, CDataSprite *pSprite)
{
int imggx = FromImageInfo.m_Width / pSprite->m_pSet->m_Gridx;
int imggy = FromImageInfo.m_Height / pSprite->m_pSet->m_Gridy;
Expand Down
3 changes: 1 addition & 2 deletions src/engine/client/graphics_threaded.h
Original file line number Diff line number Diff line change
Expand Up @@ -976,10 +976,9 @@ class CGraphics_Threaded : public IEngineGraphics

CTextureHandle LoadSpriteTextureImpl(CImageInfo &FromImageInfo, int x, int y, size_t w, size_t h);
CTextureHandle LoadSpriteTexture(CImageInfo &FromImageInfo, struct CDataSprite *pSprite) override;
CTextureHandle LoadSpriteTexture(CImageInfo &FromImageInfo, struct client_data7::CDataSprite *pSprite) override;

bool IsImageSubFullyTransparent(CImageInfo &FromImageInfo, int x, int y, int w, int h) override;
bool IsSpriteTextureFullyTransparent(CImageInfo &FromImageInfo, struct client_data7::CDataSprite *pSprite) override;
bool IsSpriteTextureFullyTransparent(CImageInfo &FromImageInfo, struct CDataSprite *pSprite) override;

// simple uncompressed RGBA loaders
IGraphics::CTextureHandle LoadTexture(const char *pFilename, int StorageType, int Flags = 0) override;
Expand Down
7 changes: 1 addition & 6 deletions src/engine/graphics.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,6 @@ typedef STWGraphicGPU TTWGraphicsGPUList;
typedef std::function<void()> WINDOW_RESIZE_FUNC;
typedef std::function<void()> WINDOW_PROPS_CHANGED_FUNC;

namespace client_data7 {
struct CDataSprite; // NOLINT(bugprone-forward-declaration-namespace)
}

typedef std::function<bool(uint32_t &Width, uint32_t &Height, CImageInfo::EImageFormat &Format, std::vector<uint8_t> &vDstData)> TGLBackendReadPresentedImageData;

class IGraphics : public IInterface
Expand Down Expand Up @@ -351,10 +347,9 @@ class IGraphics : public IInterface
virtual bool UpdateTextTexture(CTextureHandle TextureID, int x, int y, size_t Width, size_t Height, const void *pData) = 0;

virtual CTextureHandle LoadSpriteTexture(CImageInfo &FromImageInfo, struct CDataSprite *pSprite) = 0;
virtual CTextureHandle LoadSpriteTexture(CImageInfo &FromImageInfo, struct client_data7::CDataSprite *pSprite) = 0;

virtual bool IsImageSubFullyTransparent(CImageInfo &FromImageInfo, int x, int y, int w, int h) = 0;
virtual bool IsSpriteTextureFullyTransparent(CImageInfo &FromImageInfo, struct client_data7::CDataSprite *pSprite) = 0;
virtual bool IsSpriteTextureFullyTransparent(CImageInfo &FromImageInfo, struct CDataSprite *pSprite) = 0;

virtual void FlushVertices(bool KeepVertices = false) = 0;
virtual void FlushVerticesTex3D() = 0;
Expand Down
7 changes: 0 additions & 7 deletions src/game/client/render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,6 @@ void CRenderTools::SelectSprite(int Id, int Flags, int sx, int sy)
SelectSprite(&g_pData->m_aSprites[Id], Flags, sx, sy);
}

void CRenderTools::GetSpriteScale(client_data7::CDataSprite *pSprite, float &ScaleX, float &ScaleY)
{
int w = pSprite->m_W;
int h = pSprite->m_H;
GetSpriteScaleImpl(w, h, ScaleX, ScaleY);
}

void CRenderTools::GetSpriteScale(struct CDataSprite *pSprite, float &ScaleX, float &ScaleY)
{
int w = pSprite->m_W;
Expand Down
1 change: 0 additions & 1 deletion src/game/client/render.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ class CRenderTools
void SelectSprite(CDataSprite *pSprite, int Flags = 0, int sx = 0, int sy = 0);
void SelectSprite(int Id, int Flags = 0, int sx = 0, int sy = 0);

void GetSpriteScale(client_data7::CDataSprite *pSprite, float &ScaleX, float &ScaleY);
void GetSpriteScale(CDataSprite *pSprite, float &ScaleX, float &ScaleY);
void GetSpriteScale(int Id, float &ScaleX, float &ScaleY);
void GetSpriteScaleImpl(int Width, int Height, float &ScaleX, float &ScaleY);
Expand Down

0 comments on commit b6470e5

Please sign in to comment.