mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-18 14:08:19 +00:00
Merge pull request #7309 from infclass/kaffeine/merge-client-data-structs
Extract client 'six' data types and use them for 'seven' data
This commit is contained in:
commit
60fa51ff13
|
@ -1801,6 +1801,7 @@ add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/src/game/generated/git_revision.
|
||||||
)
|
)
|
||||||
generate_source("src/game/generated/client_data.cpp" "client_content_source")
|
generate_source("src/game/generated/client_data.cpp" "client_content_source")
|
||||||
generate_source("src/game/generated/client_data.h" "client_content_header")
|
generate_source("src/game/generated/client_data.h" "client_content_header")
|
||||||
|
generate_source("src/game/generated/data_types.h" "content_types_header")
|
||||||
generate_source("src/game/generated/protocol.cpp" "network_source")
|
generate_source("src/game/generated/protocol.cpp" "network_source")
|
||||||
generate_source("src/game/generated/protocol.h" "network_header")
|
generate_source("src/game/generated/protocol.h" "network_header")
|
||||||
generate_source("src/game/generated/server_data.cpp" "server_content_source")
|
generate_source("src/game/generated/server_data.cpp" "server_content_source")
|
||||||
|
@ -2022,6 +2023,7 @@ foreach(s ${GAME_SHARED})
|
||||||
endforeach()
|
endforeach()
|
||||||
list(REMOVE_ITEM GAME_SHARED ${ENGINE_UUID_SHARED})
|
list(REMOVE_ITEM GAME_SHARED ${ENGINE_UUID_SHARED})
|
||||||
set(GAME_GENERATED_SHARED
|
set(GAME_GENERATED_SHARED
|
||||||
|
src/game/generated/data_types.h
|
||||||
src/game/generated/git_revision.cpp
|
src/game/generated/git_revision.cpp
|
||||||
src/game/generated/protocol.h
|
src/game/generated/protocol.h
|
||||||
src/game/generated/protocol7.h
|
src/game/generated/protocol7.h
|
||||||
|
|
|
@ -365,7 +365,7 @@ void RegisterGameUuids(CUuidManager *pManager)
|
||||||
print(line)
|
print(line)
|
||||||
|
|
||||||
|
|
||||||
def gen_common_content_header():
|
def gen_common_content_types_header():
|
||||||
# print some includes
|
# print some includes
|
||||||
print('#include <engine/graphics.h>')
|
print('#include <engine/graphics.h>')
|
||||||
|
|
||||||
|
@ -380,6 +380,11 @@ def gen_common_content_header():
|
||||||
for name in order:
|
for name in order:
|
||||||
EmitTypeDeclaration(content.__dict__[name])
|
EmitTypeDeclaration(content.__dict__[name])
|
||||||
|
|
||||||
|
|
||||||
|
def gen_common_content_header():
|
||||||
|
# print some includes
|
||||||
|
print('#include "data_types.h"')
|
||||||
|
|
||||||
# the container pointer
|
# the container pointer
|
||||||
print('extern CDataContainer *g_pData;')
|
print('extern CDataContainer *g_pData;')
|
||||||
|
|
||||||
|
@ -392,6 +397,14 @@ def gen_common_content_source():
|
||||||
EmitDefinition(content.container, "datacontainer")
|
EmitDefinition(content.container, "datacontainer")
|
||||||
print('CDataContainer *g_pData = &datacontainer;')
|
print('CDataContainer *g_pData = &datacontainer;')
|
||||||
|
|
||||||
|
|
||||||
|
def gen_content_types_header():
|
||||||
|
print("#ifndef CONTENT_TYPES_HEADER")
|
||||||
|
print("#define CONTENT_TYPES_HEADER")
|
||||||
|
gen_common_content_types_header()
|
||||||
|
print("#endif")
|
||||||
|
|
||||||
|
|
||||||
def gen_client_content_header():
|
def gen_client_content_header():
|
||||||
print("#ifndef CLIENT_CONTENT_HEADER")
|
print("#ifndef CLIENT_CONTENT_HEADER")
|
||||||
print("#define CLIENT_CONTENT_HEADER")
|
print("#define CLIENT_CONTENT_HEADER")
|
||||||
|
@ -423,6 +436,7 @@ def main():
|
||||||
FUNCTION_MAP = {
|
FUNCTION_MAP = {
|
||||||
'network_header': gen_network_header,
|
'network_header': gen_network_header,
|
||||||
'network_source': gen_network_source,
|
'network_source': gen_network_source,
|
||||||
|
'content_types_header': gen_content_types_header,
|
||||||
'client_content_header': gen_client_content_header,
|
'client_content_header': gen_client_content_header,
|
||||||
'client_content_source': gen_client_content_source,
|
'client_content_source': gen_client_content_source,
|
||||||
'server_content_header': gen_server_content_header,
|
'server_content_header': gen_server_content_header,
|
||||||
|
|
|
@ -16,10 +16,11 @@ class SoundSet(Struct):
|
||||||
self.sounds.Add(Sound(filename))
|
self.sounds.Add(Sound(filename))
|
||||||
|
|
||||||
class Image(Struct):
|
class Image(Struct):
|
||||||
def __init__(self, name="", filename=""):
|
def __init__(self, name="", filename="", linear_mapping=0):
|
||||||
Struct.__init__(self, "CDataImage")
|
Struct.__init__(self, "CDataImage")
|
||||||
self.name = String(name)
|
self.name = String(name)
|
||||||
self.filename = String(filename)
|
self.filename = String(filename)
|
||||||
|
self.flag = Int(linear_mapping)
|
||||||
self.id = TextureHandle()
|
self.id = TextureHandle()
|
||||||
|
|
||||||
class SpriteSet(Struct):
|
class SpriteSet(Struct):
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import sys
|
import sys
|
||||||
from .datatypes import EmitDefinition, EmitTypeDeclaration
|
from .datatypes import EmitDefinition
|
||||||
from . import content # pylint: disable=no-name-in-module
|
from . import content # pylint: disable=no-name-in-module
|
||||||
from . import network # pylint: disable=no-name-in-module
|
from . import network # pylint: disable=no-name-in-module
|
||||||
|
|
||||||
|
@ -60,20 +60,9 @@ def main():
|
||||||
if gen_client_content_header or gen_server_content_header:
|
if gen_client_content_header or gen_server_content_header:
|
||||||
# print some includes
|
# print some includes
|
||||||
print('#include <engine/graphics.h>')
|
print('#include <engine/graphics.h>')
|
||||||
print('#include <engine/sound.h>')
|
print('#include "data_types.h"')
|
||||||
print("namespace client_data7 {")
|
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
|
# the container pointer
|
||||||
print('extern CDataContainer *g_pData;')
|
print('extern CDataContainer *g_pData;')
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
from .datatypes import Array, Float, Int, Pointer, SampleHandle, String, Struct, TextureHandle
|
from .datatypes import Array, Float, Int, Pointer, String, Struct, TextureHandle
|
||||||
|
|
||||||
class Sound(Struct):
|
class Sound(Struct):
|
||||||
def __init__(self, filename=""):
|
def __init__(self, filename=""):
|
||||||
Struct.__init__(self, "CDataSound")
|
Struct.__init__(self, "CDataSound")
|
||||||
self.id = SampleHandle()
|
self.id = Int(0)
|
||||||
self.filename = String(filename)
|
self.filename = String(filename)
|
||||||
|
|
||||||
class SoundSet(Struct):
|
class SoundSet(Struct):
|
||||||
|
|
|
@ -382,17 +382,6 @@ IGraphics::CTextureHandle CGraphics_Threaded::LoadSpriteTexture(CImageInfo &From
|
||||||
return LoadSpriteTextureImpl(FromImageInfo, x, y, w, h);
|
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)
|
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)
|
if(FromImageInfo.m_Format == CImageInfo::FORMAT_SINGLE_COMPONENT || FromImageInfo.m_Format == CImageInfo::FORMAT_RGBA)
|
||||||
|
@ -414,7 +403,7 @@ bool CGraphics_Threaded::IsImageSubFullyTransparent(CImageInfo &FromImageInfo, i
|
||||||
return false;
|
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 imggx = FromImageInfo.m_Width / pSprite->m_pSet->m_Gridx;
|
||||||
int imggy = FromImageInfo.m_Height / pSprite->m_pSet->m_Gridy;
|
int imggy = FromImageInfo.m_Height / pSprite->m_pSet->m_Gridy;
|
||||||
|
|
|
@ -976,10 +976,9 @@ public:
|
||||||
|
|
||||||
CTextureHandle LoadSpriteTextureImpl(CImageInfo &FromImageInfo, int x, int y, size_t w, size_t h);
|
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 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 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
|
// simple uncompressed RGBA loaders
|
||||||
IGraphics::CTextureHandle LoadTexture(const char *pFilename, int StorageType, int Flags = 0) override;
|
IGraphics::CTextureHandle LoadTexture(const char *pFilename, int StorageType, int Flags = 0) override;
|
||||||
|
|
|
@ -228,10 +228,6 @@ typedef STWGraphicGPU TTWGraphicsGPUList;
|
||||||
typedef std::function<void()> WINDOW_RESIZE_FUNC;
|
typedef std::function<void()> WINDOW_RESIZE_FUNC;
|
||||||
typedef std::function<void()> WINDOW_PROPS_CHANGED_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;
|
typedef std::function<bool(uint32_t &Width, uint32_t &Height, CImageInfo::EImageFormat &Format, std::vector<uint8_t> &vDstData)> TGLBackendReadPresentedImageData;
|
||||||
|
|
||||||
class IGraphics : public IInterface
|
class IGraphics : public IInterface
|
||||||
|
@ -351,10 +347,9 @@ public:
|
||||||
virtual bool UpdateTextTexture(CTextureHandle TextureID, int x, int y, size_t Width, size_t Height, const void *pData) = 0;
|
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 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 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 FlushVertices(bool KeepVertices = false) = 0;
|
||||||
virtual void FlushVerticesTex3D() = 0;
|
virtual void FlushVerticesTex3D() = 0;
|
||||||
|
|
|
@ -90,13 +90,6 @@ void CRenderTools::SelectSprite(int Id, int Flags, int sx, int sy)
|
||||||
SelectSprite(&g_pData->m_aSprites[Id], Flags, sx, 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)
|
void CRenderTools::GetSpriteScale(struct CDataSprite *pSprite, float &ScaleX, float &ScaleY)
|
||||||
{
|
{
|
||||||
int w = pSprite->m_W;
|
int w = pSprite->m_W;
|
||||||
|
|
|
@ -134,7 +134,6 @@ public:
|
||||||
void SelectSprite(CDataSprite *pSprite, int Flags = 0, int sx = 0, int sy = 0);
|
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 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(CDataSprite *pSprite, float &ScaleX, float &ScaleY);
|
||||||
void GetSpriteScale(int Id, float &ScaleX, float &ScaleY);
|
void GetSpriteScale(int Id, float &ScaleX, float &ScaleY);
|
||||||
void GetSpriteScaleImpl(int Width, int Height, float &ScaleX, float &ScaleY);
|
void GetSpriteScaleImpl(int Width, int Height, float &ScaleX, float &ScaleY);
|
||||||
|
|
Loading…
Reference in a new issue