mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 14:38:18 +00:00
Merge branch 'master' of github.com:teeworlds/teeworlds
Conflicts: src/game/client/gameclient.cpp src/game/server/gamecontext.cpp
This commit is contained in:
commit
f25010d9dd
36
.gitignore
vendored
36
.gitignore
vendored
|
@ -1,24 +1,24 @@
|
|||
bam
|
||||
.bam
|
||||
config.lua
|
||||
objs
|
||||
/bam
|
||||
/.bam
|
||||
/config.lua
|
||||
/objs
|
||||
__pycache__/
|
||||
*.pyc
|
||||
*.pyo
|
||||
scripts/work/
|
||||
src/game/generated/
|
||||
SDL.dll
|
||||
freetype.dll
|
||||
autoexec.cfg
|
||||
/SDL.dll
|
||||
/freetype.dll
|
||||
/autoexec.cfg
|
||||
|
||||
crapnet*
|
||||
dilate*
|
||||
fake_server*
|
||||
map_resave*
|
||||
map_version*
|
||||
mastersrv*
|
||||
packetgen*
|
||||
teeworlds*
|
||||
teeworlds_srv*
|
||||
tileset_border*
|
||||
versionsrv*
|
||||
/crapnet*
|
||||
/dilate*
|
||||
/fake_server*
|
||||
/map_resave*
|
||||
/map_version*
|
||||
/mastersrv*
|
||||
/packetgen*
|
||||
/teeworlds*
|
||||
/teeworlds_srv*
|
||||
/tileset_border*
|
||||
/versionsrv*
|
||||
|
|
|
@ -64,6 +64,10 @@ if gen_server_content_header:
|
|||
|
||||
|
||||
if gen_client_content_header or gen_server_content_header:
|
||||
# print some includes
|
||||
print('#include <engine/graphics.h>')
|
||||
print('#include <engine/sound.h>')
|
||||
|
||||
# emit the type declarations
|
||||
contentlines = open("datasrc/content.py", "rb").readlines()
|
||||
order = []
|
||||
|
|
|
@ -4,7 +4,7 @@ from datatypes import *
|
|||
class Sound(Struct):
|
||||
def __init__(self, filename=""):
|
||||
Struct.__init__(self, "CDataSound")
|
||||
self.id = Int(0)
|
||||
self.id = SampleHandle()
|
||||
self.filename = String(filename)
|
||||
|
||||
class SoundSet(Struct):
|
||||
|
@ -21,7 +21,7 @@ class Image(Struct):
|
|||
Struct.__init__(self, "CDataImage")
|
||||
self.name = String(name)
|
||||
self.filename = String(filename)
|
||||
self.id = Int(-1)
|
||||
self.id = TextureHandle()
|
||||
|
||||
class SpriteSet(Struct):
|
||||
def __init__(self, name="", image=None, gridx=0, gridy=0):
|
||||
|
|
|
@ -168,6 +168,18 @@ class Pointer(BaseType):
|
|||
def EmitDefinition(self, name):
|
||||
return ["&"+self.target.TargetName()]
|
||||
|
||||
class TextureHandle(BaseType):
|
||||
def __init__(self):
|
||||
BaseType.__init__(self, "IGraphics::CTextureHandle")
|
||||
def EmitDefinition(self, name):
|
||||
return ["IGraphics::CTextureHandle()"]
|
||||
|
||||
class SampleHandle(BaseType):
|
||||
def __init__(self):
|
||||
BaseType.__init__(self, "ISound::CSampleHandle")
|
||||
def EmitDefinition(self, name):
|
||||
return ["ISound::CSampleHandle()"]
|
||||
|
||||
# helper functions
|
||||
|
||||
def EmitTypeDeclaration(root):
|
||||
|
|
|
@ -80,7 +80,7 @@ void dbg_assert_imp(const char *filename, int line, int test, const char *msg)
|
|||
|
||||
void dbg_break()
|
||||
{
|
||||
*((unsigned*)0) = 0x0;
|
||||
*((volatile unsigned*)0) = 0x0;
|
||||
}
|
||||
|
||||
void dbg_msg(const char *sys, const char *fmt, ...)
|
||||
|
@ -166,6 +166,8 @@ void *mem_alloc_debug(const char *filename, int line, unsigned size, unsigned al
|
|||
MEMTAIL *tail;
|
||||
MEMHEADER *header = (struct MEMHEADER *)malloc(size+sizeof(MEMHEADER)+sizeof(MEMTAIL));
|
||||
dbg_assert(header != 0, "mem_alloc failure");
|
||||
if(!header)
|
||||
return NULL;
|
||||
tail = (struct MEMTAIL *)(((char*)(header+1))+size);
|
||||
header->size = size;
|
||||
header->filename = filename;
|
||||
|
|
|
@ -33,6 +33,13 @@ void dbg_assert(int test, const char *msg);
|
|||
#define dbg_assert(test,msg) dbg_assert_imp(__FILE__, __LINE__, test, msg)
|
||||
void dbg_assert_imp(const char *filename, int line, int test, const char *msg);
|
||||
|
||||
|
||||
#ifdef __clang_analyzer__
|
||||
#include <assert.h>
|
||||
#undef dbg_assert
|
||||
#define dbg_assert(test,msg) assert(test)
|
||||
#endif
|
||||
|
||||
/*
|
||||
Function: dbg_break
|
||||
Breaks into the debugger.
|
||||
|
|
|
@ -154,7 +154,7 @@ public:
|
|||
void pop_back() { tl_assert(!empty()); end--; }
|
||||
T& front() { tl_assert(!empty()); return *begin; }
|
||||
T& back() { tl_assert(!empty()); return *(end-1); }
|
||||
T& index(unsigned i) { tl_assert(i >= 0 && i < (unsigned)(end-begin)); return begin[i]; }
|
||||
T& index(unsigned i) { tl_assert(i < (unsigned)(end-begin)); return begin[i]; }
|
||||
unsigned size() const { return (unsigned)(end-begin); }
|
||||
plain_range slice(unsigned startindex, unsigned endindex)
|
||||
{
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "kernel.h"
|
||||
|
||||
#include "message.h"
|
||||
#include "graphics.h"
|
||||
|
||||
class IClient : public IInterface
|
||||
{
|
||||
|
@ -143,7 +144,7 @@ public:
|
|||
|
||||
virtual bool SoundInitFailed() = 0;
|
||||
|
||||
virtual int GetDebugFont() = 0;
|
||||
virtual IGraphics::CTextureHandle GetDebugFont() = 0; // TODO: remove this function
|
||||
};
|
||||
|
||||
class IGameClient : public IInterface
|
||||
|
|
|
@ -94,12 +94,12 @@ void CGraph::Add(float v, float r, float g, float b)
|
|||
m_aColors[m_Index][2] = b;
|
||||
}
|
||||
|
||||
void CGraph::Render(IGraphics *pGraphics, int Font, float x, float y, float w, float h, const char *pDescription)
|
||||
void CGraph::Render(IGraphics *pGraphics, IGraphics::CTextureHandle FontTexture, float x, float y, float w, float h, const char *pDescription)
|
||||
{
|
||||
//m_pGraphics->BlendNormal();
|
||||
|
||||
|
||||
pGraphics->TextureSet(-1);
|
||||
pGraphics->TextureClear();
|
||||
|
||||
pGraphics->QuadsBegin();
|
||||
pGraphics->SetColor(0, 0, 0, 0.75f);
|
||||
|
@ -136,7 +136,7 @@ void CGraph::Render(IGraphics *pGraphics, int Font, float x, float y, float w, f
|
|||
}
|
||||
pGraphics->LinesEnd();
|
||||
|
||||
pGraphics->TextureSet(Font);
|
||||
pGraphics->TextureSet(FontTexture);
|
||||
pGraphics->QuadsText(x+2, y+h-16, 16, 1,1,1,1, pDescription);
|
||||
|
||||
char aBuf[32];
|
||||
|
@ -1300,7 +1300,6 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket)
|
|||
}
|
||||
|
||||
// unpack delta
|
||||
PurgeTick = DeltaTick;
|
||||
SnapSize = m_SnapshotDelta.UnpackDelta(pDeltaShot, pTmpBuffer3, pDeltaData, DeltaSize);
|
||||
if(SnapSize < 0)
|
||||
{
|
||||
|
@ -1339,7 +1338,7 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket)
|
|||
if(m_aSnapshots[SNAP_PREV] && m_aSnapshots[SNAP_PREV]->m_Tick < PurgeTick)
|
||||
PurgeTick = m_aSnapshots[SNAP_PREV]->m_Tick;
|
||||
if(m_aSnapshots[SNAP_CURRENT] && m_aSnapshots[SNAP_CURRENT]->m_Tick < PurgeTick)
|
||||
PurgeTick = m_aSnapshots[SNAP_PREV]->m_Tick;
|
||||
PurgeTick = m_aSnapshots[SNAP_CURRENT]->m_Tick;
|
||||
m_SnapshotStorage.PurgeUntil(PurgeTick);
|
||||
|
||||
// add new
|
||||
|
|
|
@ -23,7 +23,7 @@ public:
|
|||
void ScaleMin();
|
||||
|
||||
void Add(float v, float r, float g, float b);
|
||||
void Render(IGraphics *pGraphics, int Font, float x, float y, float w, float h, const char *pDescription);
|
||||
void Render(IGraphics *pGraphics, IGraphics::CTextureHandle FontTexture, float x, float y, float w, float h, const char *pDescription);
|
||||
};
|
||||
|
||||
|
||||
|
@ -83,7 +83,7 @@ class CClient : public IClient, public CDemoPlayer::IListner
|
|||
unsigned m_SnapshotParts;
|
||||
int64 m_LocalStartTime;
|
||||
|
||||
int m_DebugFont;
|
||||
IGraphics::CTextureHandle m_DebugFont;
|
||||
|
||||
int64 m_LastRenderTime;
|
||||
float m_RenderFrameTimeLow;
|
||||
|
@ -212,7 +212,7 @@ public:
|
|||
|
||||
virtual bool SoundInitFailed() { return m_SoundInitFailed; }
|
||||
|
||||
virtual int GetDebugFont() { return m_DebugFont; }
|
||||
virtual IGraphics::CTextureHandle GetDebugFont() { return m_DebugFont; }
|
||||
|
||||
void DirectInput(int *pInput, int Size);
|
||||
void SendInput();
|
||||
|
|
|
@ -165,7 +165,6 @@ CGraphics_OpenGL::CGraphics_OpenGL()
|
|||
|
||||
m_Rotation = 0;
|
||||
m_Drawing = 0;
|
||||
m_InvalidTexture = 0;
|
||||
|
||||
m_TextureMemoryUsage = 0;
|
||||
|
||||
|
@ -282,22 +281,22 @@ void CGraphics_OpenGL::LinesDraw(const CLineItem *pArray, int Num)
|
|||
AddVertices(2*Num);
|
||||
}
|
||||
|
||||
int CGraphics_OpenGL::UnloadTexture(int Index)
|
||||
int CGraphics_OpenGL::UnloadTexture(IGraphics::CTextureHandle Index)
|
||||
{
|
||||
if(Index == m_InvalidTexture)
|
||||
if(Index.Id() == m_InvalidTexture.Id())
|
||||
return 0;
|
||||
|
||||
if(Index < 0)
|
||||
if(!Index.IsValid())
|
||||
return 0;
|
||||
|
||||
glDeleteTextures(1, &m_aTextures[Index].m_Tex);
|
||||
m_aTextures[Index].m_Next = m_FirstFreeTexture;
|
||||
m_TextureMemoryUsage -= m_aTextures[Index].m_MemSize;
|
||||
m_FirstFreeTexture = Index;
|
||||
glDeleteTextures(1, &m_aTextures[Index.Id()].m_Tex);
|
||||
m_aTextures[Index.Id()].m_Next = m_FirstFreeTexture;
|
||||
m_TextureMemoryUsage -= m_aTextures[Index.Id()].m_MemSize;
|
||||
m_FirstFreeTexture = Index.Id();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CGraphics_OpenGL::LoadTextureRawSub(int TextureID, int x, int y, int Width, int Height, int Format, const void *pData)
|
||||
int CGraphics_OpenGL::LoadTextureRawSub(IGraphics::CTextureHandle TextureID, int x, int y, int Width, int Height, int Format, const void *pData)
|
||||
{
|
||||
int Oglformat = GL_RGBA;
|
||||
if(Format == CImageInfo::FORMAT_RGB)
|
||||
|
@ -305,12 +304,12 @@ int CGraphics_OpenGL::LoadTextureRawSub(int TextureID, int x, int y, int Width,
|
|||
else if(Format == CImageInfo::FORMAT_ALPHA)
|
||||
Oglformat = GL_ALPHA;
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, m_aTextures[TextureID].m_Tex);
|
||||
glBindTexture(GL_TEXTURE_2D, m_aTextures[TextureID.Id()].m_Tex);
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, Width, Height, Oglformat, GL_UNSIGNED_BYTE, pData);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CGraphics_OpenGL::LoadTextureRaw(int Width, int Height, int Format, const void *pData, int StoreFormat, int Flags)
|
||||
IGraphics::CTextureHandle CGraphics_OpenGL::LoadTextureRaw(int Width, int Height, int Format, const void *pData, int StoreFormat, int Flags)
|
||||
{
|
||||
int Mipmap = 1;
|
||||
unsigned char *pTexData = (unsigned char *)pData;
|
||||
|
@ -321,7 +320,7 @@ int CGraphics_OpenGL::LoadTextureRaw(int Width, int Height, int Format, const vo
|
|||
|
||||
// don't waste memory on texture if we are stress testing
|
||||
if(g_Config.m_DbgStress)
|
||||
return m_InvalidTexture;
|
||||
return m_InvalidTexture;
|
||||
|
||||
// grab texture
|
||||
Tex = m_FirstFreeTexture;
|
||||
|
@ -411,18 +410,18 @@ int CGraphics_OpenGL::LoadTextureRaw(int Width, int Height, int Format, const vo
|
|||
|
||||
m_TextureMemoryUsage += m_aTextures[Tex].m_MemSize;
|
||||
mem_free(pTmpData);
|
||||
return Tex;
|
||||
return CreateTextureHandle(Tex);
|
||||
}
|
||||
|
||||
// simple uncompressed RGBA loaders
|
||||
int CGraphics_OpenGL::LoadTexture(const char *pFilename, int StorageType, int StoreFormat, int Flags)
|
||||
IGraphics::CTextureHandle CGraphics_OpenGL::LoadTexture(const char *pFilename, int StorageType, int StoreFormat, int Flags)
|
||||
{
|
||||
int l = str_length(pFilename);
|
||||
int ID;
|
||||
IGraphics::CTextureHandle ID;
|
||||
CImageInfo Img;
|
||||
|
||||
if(l < 3)
|
||||
return -1;
|
||||
return m_InvalidTexture;
|
||||
if(LoadPNG(&Img, pFilename, StorageType))
|
||||
{
|
||||
if (StoreFormat == CImageInfo::FORMAT_AUTO)
|
||||
|
@ -430,8 +429,6 @@ int CGraphics_OpenGL::LoadTexture(const char *pFilename, int StorageType, int St
|
|||
|
||||
ID = LoadTextureRaw(Img.m_Width, Img.m_Height, Img.m_Format, Img.m_pData, StoreFormat, Flags);
|
||||
mem_free(Img.m_pData);
|
||||
if(ID != m_InvalidTexture && g_Config.m_Debug)
|
||||
dbg_msg("graphics/texture", "loaded %s", pFilename);
|
||||
return ID;
|
||||
}
|
||||
|
||||
|
@ -530,17 +527,17 @@ void CGraphics_OpenGL::ScreenshotDirect(const char *pFilename)
|
|||
mem_free(pPixelData);
|
||||
}
|
||||
|
||||
void CGraphics_OpenGL::TextureSet(int TextureID)
|
||||
void CGraphics_OpenGL::TextureSet(IGraphics::CTextureHandle Texture)
|
||||
{
|
||||
dbg_assert(m_Drawing == 0, "called Graphics()->TextureSet within begin");
|
||||
if(TextureID == -1)
|
||||
if(Texture.IsValid())
|
||||
{
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glBindTexture(GL_TEXTURE_2D, m_aTextures[Texture.Id()].m_Tex);
|
||||
}
|
||||
else
|
||||
{
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glBindTexture(GL_TEXTURE_2D, m_aTextures[TextureID].m_Tex);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ protected:
|
|||
float m_ScreenX1;
|
||||
float m_ScreenY1;
|
||||
|
||||
int m_InvalidTexture;
|
||||
IGraphics::CTextureHandle m_InvalidTexture;
|
||||
|
||||
struct CTexture
|
||||
{
|
||||
|
@ -90,17 +90,17 @@ public:
|
|||
virtual void LinesEnd();
|
||||
virtual void LinesDraw(const CLineItem *pArray, int Num);
|
||||
|
||||
virtual int UnloadTexture(int Index);
|
||||
virtual int LoadTextureRaw(int Width, int Height, int Format, const void *pData, int StoreFormat, int Flags);
|
||||
virtual int LoadTextureRawSub(int TextureID, int x, int y, int Width, int Height, int Format, const void *pData);
|
||||
virtual int UnloadTexture(IGraphics::CTextureHandle Index);
|
||||
virtual IGraphics::CTextureHandle LoadTextureRaw(int Width, int Height, int Format, const void *pData, int StoreFormat, int Flags);
|
||||
virtual int LoadTextureRawSub(IGraphics::CTextureHandle TextureID, int x, int y, int Width, int Height, int Format, const void *pData);
|
||||
|
||||
// simple uncompressed RGBA loaders
|
||||
virtual int LoadTexture(const char *pFilename, int StorageType, int StoreFormat, int Flags);
|
||||
virtual IGraphics::CTextureHandle LoadTexture(const char *pFilename, int StorageType, int StoreFormat, int Flags);
|
||||
virtual int LoadPNG(CImageInfo *pImg, const char *pFilename, int StorageType);
|
||||
|
||||
void ScreenshotDirect(const char *pFilename);
|
||||
|
||||
virtual void TextureSet(int TextureID);
|
||||
virtual void TextureSet(IGraphics::CTextureHandle TextureID);
|
||||
|
||||
virtual void Clear(float r, float g, float b);
|
||||
|
||||
|
|
|
@ -169,7 +169,6 @@ CGraphics_Threaded::CGraphics_Threaded()
|
|||
|
||||
m_Rotation = 0;
|
||||
m_Drawing = 0;
|
||||
m_InvalidTexture = 0;
|
||||
|
||||
m_TextureMemoryUsage = 0;
|
||||
|
||||
|
@ -281,21 +280,21 @@ void CGraphics_Threaded::LinesDraw(const CLineItem *pArray, int Num)
|
|||
AddVertices(2*Num);
|
||||
}
|
||||
|
||||
int CGraphics_Threaded::UnloadTexture(int Index)
|
||||
int CGraphics_Threaded::UnloadTexture(CTextureHandle Index)
|
||||
{
|
||||
if(Index == m_InvalidTexture)
|
||||
if(Index.Id() == m_InvalidTexture.Id())
|
||||
return 0;
|
||||
|
||||
if(Index < 0)
|
||||
if(!Index.IsValid())
|
||||
return 0;
|
||||
|
||||
CCommandBuffer::SCommand_Texture_Destroy Cmd;
|
||||
Cmd.m_Slot = Index;
|
||||
Cmd.m_Slot = Index.Id();
|
||||
m_pCommandBuffer->AddCommand(Cmd);
|
||||
|
||||
m_aTextures[Index].m_Next = m_FirstFreeTexture;
|
||||
m_TextureMemoryUsage -= m_aTextures[Index].m_MemSize;
|
||||
m_FirstFreeTexture = Index;
|
||||
m_aTextures[Index.Id()].m_Next = m_FirstFreeTexture;
|
||||
m_TextureMemoryUsage -= m_aTextures[Index.Id()].m_MemSize;
|
||||
m_FirstFreeTexture = Index.Id();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -308,10 +307,10 @@ static int ImageFormatToTexFormat(int Format)
|
|||
}
|
||||
|
||||
|
||||
int CGraphics_Threaded::LoadTextureRawSub(int TextureID, int x, int y, int Width, int Height, int Format, const void *pData)
|
||||
int CGraphics_Threaded::LoadTextureRawSub(CTextureHandle TextureID, int x, int y, int Width, int Height, int Format, const void *pData)
|
||||
{
|
||||
CCommandBuffer::SCommand_Texture_Update Cmd;
|
||||
Cmd.m_Slot = TextureID;
|
||||
Cmd.m_Slot = TextureID.Id();
|
||||
Cmd.m_X = x;
|
||||
Cmd.m_Y = y;
|
||||
Cmd.m_Width = Width;
|
||||
|
@ -337,7 +336,7 @@ int CGraphics_Threaded::LoadTextureRawSub(int TextureID, int x, int y, int Width
|
|||
return 0;
|
||||
}
|
||||
|
||||
int CGraphics_Threaded::LoadTextureRaw(int Width, int Height, int Format, const void *pData, int StoreFormat, int Flags)
|
||||
IGraphics::CTextureHandle CGraphics_Threaded::LoadTextureRaw(int Width, int Height, int Format, const void *pData, int StoreFormat, int Flags)
|
||||
{
|
||||
// don't waste memory on texture if we are stress testing
|
||||
if(g_Config.m_DbgStress)
|
||||
|
@ -388,18 +387,18 @@ int CGraphics_Threaded::LoadTextureRaw(int Width, int Height, int Format, const
|
|||
|
||||
m_TextureMemoryUsage += MemUsage;
|
||||
//mem_free(pTmpData);
|
||||
return Tex;
|
||||
return CreateTextureHandle(Tex);
|
||||
}
|
||||
|
||||
// simple uncompressed RGBA loaders
|
||||
int CGraphics_Threaded::LoadTexture(const char *pFilename, int StorageType, int StoreFormat, int Flags)
|
||||
IGraphics::CTextureHandle CGraphics_Threaded::LoadTexture(const char *pFilename, int StorageType, int StoreFormat, int Flags)
|
||||
{
|
||||
int l = str_length(pFilename);
|
||||
int ID;
|
||||
IGraphics::CTextureHandle ID;
|
||||
CImageInfo Img;
|
||||
|
||||
if(l < 3)
|
||||
return -1;
|
||||
return CTextureHandle();
|
||||
if(LoadPNG(&Img, pFilename, StorageType))
|
||||
{
|
||||
if (StoreFormat == CImageInfo::FORMAT_AUTO)
|
||||
|
@ -407,7 +406,7 @@ int CGraphics_Threaded::LoadTexture(const char *pFilename, int StorageType, int
|
|||
|
||||
ID = LoadTextureRaw(Img.m_Width, Img.m_Height, Img.m_Format, Img.m_pData, StoreFormat, Flags);
|
||||
mem_free(Img.m_pData);
|
||||
if(ID != m_InvalidTexture && g_Config.m_Debug)
|
||||
if(ID.Id() != m_InvalidTexture.Id() && g_Config.m_Debug)
|
||||
dbg_msg("graphics/texture", "loaded %s", pFilename);
|
||||
return ID;
|
||||
}
|
||||
|
@ -509,10 +508,10 @@ void CGraphics_Threaded::ScreenshotDirect(const char *pFilename)
|
|||
}
|
||||
}
|
||||
|
||||
void CGraphics_Threaded::TextureSet(int TextureID)
|
||||
void CGraphics_Threaded::TextureSet(CTextureHandle TextureID)
|
||||
{
|
||||
dbg_assert(m_Drawing == 0, "called Graphics()->TextureSet within begin");
|
||||
m_State.m_Texture = TextureID;
|
||||
m_State.m_Texture = TextureID.Id();
|
||||
}
|
||||
|
||||
void CGraphics_Threaded::Clear(float r, float g, float b)
|
||||
|
|
|
@ -296,6 +296,8 @@ public:
|
|||
INITFLAG_BORDERLESS = 8,
|
||||
};
|
||||
|
||||
virtual ~IGraphicsBackend() {}
|
||||
|
||||
virtual int Init(const char *pName, int *Width, int *Height, int FsaaSamples, int Flags) = 0;
|
||||
virtual int Shutdown() = 0;
|
||||
|
||||
|
@ -346,7 +348,7 @@ class CGraphics_Threaded : public IEngineGraphics
|
|||
bool m_DoScreenshot;
|
||||
char m_aScreenshotName[128];
|
||||
|
||||
int m_InvalidTexture;
|
||||
CTextureHandle m_InvalidTexture;
|
||||
|
||||
struct CTexture
|
||||
{
|
||||
|
@ -393,17 +395,17 @@ public:
|
|||
virtual void LinesEnd();
|
||||
virtual void LinesDraw(const CLineItem *pArray, int Num);
|
||||
|
||||
virtual int UnloadTexture(int Index);
|
||||
virtual int LoadTextureRaw(int Width, int Height, int Format, const void *pData, int StoreFormat, int Flags);
|
||||
virtual int LoadTextureRawSub(int TextureID, int x, int y, int Width, int Height, int Format, const void *pData);
|
||||
virtual int UnloadTexture(IGraphics::CTextureHandle Index);
|
||||
virtual IGraphics::CTextureHandle LoadTextureRaw(int Width, int Height, int Format, const void *pData, int StoreFormat, int Flags);
|
||||
virtual int LoadTextureRawSub(IGraphics::CTextureHandle TextureID, int x, int y, int Width, int Height, int Format, const void *pData);
|
||||
|
||||
// simple uncompressed RGBA loaders
|
||||
virtual int LoadTexture(const char *pFilename, int StorageType, int StoreFormat, int Flags);
|
||||
virtual IGraphics::CTextureHandle LoadTexture(const char *pFilename, int StorageType, int StoreFormat, int Flags);
|
||||
virtual int LoadPNG(CImageInfo *pImg, const char *pFilename, int StorageType);
|
||||
|
||||
void ScreenshotDirect(const char *pFilename);
|
||||
|
||||
virtual void TextureSet(int TextureID);
|
||||
virtual void TextureSet(CTextureHandle TextureID);
|
||||
|
||||
virtual void Clear(float r, float g, float b);
|
||||
|
||||
|
|
|
@ -333,7 +333,7 @@ int CSound::ReadData(void *pBuffer, int Size)
|
|||
return io_read(ms_File, pBuffer, Size);
|
||||
}
|
||||
|
||||
int CSound::LoadWV(const char *pFilename)
|
||||
ISound::CSampleHandle CSound::LoadWV(const char *pFilename)
|
||||
{
|
||||
CSample *pSample;
|
||||
int SampleID = -1;
|
||||
|
@ -342,20 +342,20 @@ int CSound::LoadWV(const char *pFilename)
|
|||
|
||||
// don't waste memory on sound when we are stress testing
|
||||
if(g_Config.m_DbgStress)
|
||||
return -1;
|
||||
return CSampleHandle();
|
||||
|
||||
// no need to load sound when we are running with no sound
|
||||
if(!m_SoundEnabled)
|
||||
return 1;
|
||||
return CSampleHandle();
|
||||
|
||||
if(!m_pStorage)
|
||||
return -1;
|
||||
return CSampleHandle();
|
||||
|
||||
ms_File = m_pStorage->OpenFile(pFilename, IOFLAG_READ, IStorage::TYPE_ALL);
|
||||
if(!ms_File)
|
||||
{
|
||||
dbg_msg("sound/wv", "failed to open file. filename='%s'", pFilename);
|
||||
return -1;
|
||||
return CSampleHandle();
|
||||
}
|
||||
|
||||
SampleID = AllocID();
|
||||
|
@ -363,7 +363,7 @@ int CSound::LoadWV(const char *pFilename)
|
|||
{
|
||||
io_close(ms_File);
|
||||
ms_File = 0;
|
||||
return -1;
|
||||
return CSampleHandle();
|
||||
}
|
||||
pSample = &m_aSamples[SampleID];
|
||||
|
||||
|
@ -387,7 +387,7 @@ int CSound::LoadWV(const char *pFilename)
|
|||
dbg_msg("sound/wv", "file is not mono or stereo. filename='%s'", pFilename);
|
||||
io_close(ms_File);
|
||||
ms_File = 0;
|
||||
return -1;
|
||||
return CSampleHandle();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -402,7 +402,7 @@ int CSound::LoadWV(const char *pFilename)
|
|||
dbg_msg("sound/wv", "bps is %d, not 16, filname='%s'", BitsPerSample, pFilename);
|
||||
io_close(ms_File);
|
||||
ms_File = 0;
|
||||
return -1;
|
||||
return CSampleHandle();
|
||||
}
|
||||
|
||||
pData = (int *)mem_alloc(4*m_aSamples*m_aChannels, 1);
|
||||
|
@ -434,7 +434,7 @@ int CSound::LoadWV(const char *pFilename)
|
|||
dbg_msg("sound/wv", "loaded %s", pFilename);
|
||||
|
||||
RateConvert(SampleID);
|
||||
return SampleID;
|
||||
return CreateSampleHandle(SampleID);
|
||||
}
|
||||
|
||||
void CSound::SetListenerPos(float x, float y)
|
||||
|
@ -450,8 +450,11 @@ void CSound::SetChannel(int ChannelID, float Vol, float Pan)
|
|||
m_aChannels[ChannelID].m_Pan = (int)(Pan*255.0f); // TODO: this is only on and off right now
|
||||
}
|
||||
|
||||
int CSound::Play(int ChannelID, int SampleID, int Flags, float x, float y)
|
||||
int CSound::Play(int ChannelID, CSampleHandle SampleID, int Flags, float x, float y)
|
||||
{
|
||||
if(!SampleID.IsValid())
|
||||
return -1;
|
||||
|
||||
int VoiceID = -1;
|
||||
int i;
|
||||
|
||||
|
@ -472,10 +475,10 @@ int CSound::Play(int ChannelID, int SampleID, int Flags, float x, float y)
|
|||
// voice found, use it
|
||||
if(VoiceID != -1)
|
||||
{
|
||||
m_aVoices[VoiceID].m_pSample = &m_aSamples[SampleID];
|
||||
m_aVoices[VoiceID].m_pSample = &m_aSamples[SampleID.Id()];
|
||||
m_aVoices[VoiceID].m_pChannel = &m_aChannels[ChannelID];
|
||||
if(Flags & FLAG_LOOP)
|
||||
m_aVoices[VoiceID].m_Tick = m_aSamples[SampleID].m_PausedAt;
|
||||
m_aVoices[VoiceID].m_Tick = m_aSamples[SampleID.Id()].m_PausedAt;
|
||||
else
|
||||
m_aVoices[VoiceID].m_Tick = 0;
|
||||
m_aVoices[VoiceID].m_Vol = 255;
|
||||
|
@ -488,21 +491,21 @@ int CSound::Play(int ChannelID, int SampleID, int Flags, float x, float y)
|
|||
return VoiceID;
|
||||
}
|
||||
|
||||
int CSound::PlayAt(int ChannelID, int SampleID, int Flags, float x, float y)
|
||||
int CSound::PlayAt(int ChannelID, CSampleHandle SampleID, int Flags, float x, float y)
|
||||
{
|
||||
return Play(ChannelID, SampleID, Flags|ISound::FLAG_POS, x, y);
|
||||
}
|
||||
|
||||
int CSound::Play(int ChannelID, int SampleID, int Flags)
|
||||
int CSound::Play(int ChannelID, CSampleHandle SampleID, int Flags)
|
||||
{
|
||||
return Play(ChannelID, SampleID, Flags, 0, 0);
|
||||
}
|
||||
|
||||
void CSound::Stop(int SampleID)
|
||||
void CSound::Stop(CSampleHandle SampleID)
|
||||
{
|
||||
// TODO: a nice fade out
|
||||
lock_wait(m_SoundLock);
|
||||
CSample *pSample = &m_aSamples[SampleID];
|
||||
CSample *pSample = &m_aSamples[SampleID.Id()];
|
||||
for(int i = 0; i < NUM_VOICES; i++)
|
||||
{
|
||||
if(m_aVoices[i].m_pSample == pSample)
|
||||
|
|
|
@ -27,15 +27,15 @@ public:
|
|||
|
||||
virtual bool IsSoundEnabled() { return m_SoundEnabled != 0; }
|
||||
|
||||
virtual int LoadWV(const char *pFilename);
|
||||
virtual CSampleHandle LoadWV(const char *pFilename);
|
||||
|
||||
virtual void SetListenerPos(float x, float y);
|
||||
virtual void SetChannel(int ChannelID, float Vol, float Pan);
|
||||
|
||||
int Play(int ChannelID, int SampleID, int Flags, float x, float y);
|
||||
virtual int PlayAt(int ChannelID, int SampleID, int Flags, float x, float y);
|
||||
virtual int Play(int ChannelID, int SampleID, int Flags);
|
||||
virtual void Stop(int SampleID);
|
||||
int Play(int ChannelID, CSampleHandle SampleID, int Flags, float x, float y);
|
||||
virtual int PlayAt(int ChannelID, CSampleHandle SampleID, int Flags, float x, float y);
|
||||
virtual int Play(int ChannelID, CSampleHandle SampleID, int Flags);
|
||||
virtual void Stop(CSampleHandle SampleID);
|
||||
virtual void StopAll();
|
||||
};
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ struct CFontSizeData
|
|||
int m_FontSize;
|
||||
FT_Face *m_pFace;
|
||||
|
||||
int m_aTextures[2];
|
||||
IGraphics::CTextureHandle m_aTextures[2];
|
||||
int m_TextureWidth;
|
||||
int m_TextureHeight;
|
||||
|
||||
|
@ -150,11 +150,11 @@ class CTextRender : public IEngineTextRender
|
|||
|
||||
for(int i = 0; i < 2; i++)
|
||||
{
|
||||
if(pSizeData->m_aTextures[i] != 0)
|
||||
if(pSizeData->m_aTextures[i].IsValid())
|
||||
{
|
||||
Graphics()->UnloadTexture(pSizeData->m_aTextures[i]);
|
||||
FontMemoryUsage -= pSizeData->m_TextureWidth*pSizeData->m_TextureHeight;
|
||||
pSizeData->m_aTextures[i] = 0;
|
||||
pSizeData->m_aTextures[i] = IGraphics::CTextureHandle();
|
||||
}
|
||||
|
||||
pSizeData->m_aTextures[i] = Graphics()->LoadTextureRaw(Width, Height, CImageInfo::FORMAT_ALPHA, pMem, CImageInfo::FORMAT_ALPHA, IGraphics::TEXLOAD_NOMIPMAPS);
|
||||
|
|
|
@ -60,6 +60,20 @@ public:
|
|||
TEXLOAD_NOMIPMAPS = 2,
|
||||
};
|
||||
|
||||
|
||||
class CTextureHandle
|
||||
{
|
||||
friend class IGraphics;
|
||||
int m_Id;
|
||||
public:
|
||||
CTextureHandle()
|
||||
: m_Id(-1)
|
||||
{}
|
||||
|
||||
bool IsValid() const { return Id() >= 0; }
|
||||
int Id() const { return m_Id; }
|
||||
};
|
||||
|
||||
int ScreenWidth() const { return m_ScreenWidth; }
|
||||
int ScreenHeight() const { return m_ScreenHeight; }
|
||||
float ScreenAspect() const { return (float)ScreenWidth()/(float)ScreenHeight(); }
|
||||
|
@ -81,11 +95,13 @@ public:
|
|||
virtual int MemoryUsage() const = 0;
|
||||
|
||||
virtual int LoadPNG(CImageInfo *pImg, const char *pFilename, int StorageType) = 0;
|
||||
virtual int UnloadTexture(int Index) = 0;
|
||||
virtual int LoadTextureRaw(int Width, int Height, int Format, const void *pData, int StoreFormat, int Flags) = 0;
|
||||
virtual int LoadTexture(const char *pFilename, int StorageType, int StoreFormat, int Flags) = 0;
|
||||
virtual int LoadTextureRawSub(int TextureID, int x, int y, int Width, int Height, int Format, const void *pData) = 0;
|
||||
virtual void TextureSet(int TextureID) = 0;
|
||||
|
||||
virtual int UnloadTexture(CTextureHandle Index) = 0;
|
||||
virtual CTextureHandle LoadTextureRaw(int Width, int Height, int Format, const void *pData, int StoreFormat, int Flags) = 0;
|
||||
virtual int LoadTextureRawSub(CTextureHandle TextureID, int x, int y, int Width, int Height, int Format, const void *pData) = 0;
|
||||
virtual CTextureHandle LoadTexture(const char *pFilename, int StorageType, int StoreFormat, int Flags) = 0;
|
||||
virtual void TextureSet(CTextureHandle Texture) = 0;
|
||||
void TextureClear() { TextureSet(CTextureHandle()); }
|
||||
|
||||
struct CLineItem
|
||||
{
|
||||
|
@ -141,6 +157,14 @@ public:
|
|||
virtual void InsertSignal(class semaphore *pSemaphore) = 0;
|
||||
virtual bool IsIdle() = 0;
|
||||
virtual void WaitForIdle() = 0;
|
||||
|
||||
protected:
|
||||
inline CTextureHandle CreateTextureHandle(int Index)
|
||||
{
|
||||
CTextureHandle Tex;
|
||||
Tex.m_Id = Index;
|
||||
return Tex;
|
||||
}
|
||||
};
|
||||
|
||||
class IEngineGraphics : public IGraphics
|
||||
|
|
|
@ -145,7 +145,7 @@ void CSnapIDPool::FreeID(int ID)
|
|||
}
|
||||
|
||||
|
||||
void CServerBan::Init(IConsole *pConsole, IStorage *pStorage, CServer* pServer)
|
||||
void CServerBan::InitServerBan(IConsole *pConsole, IStorage *pStorage, CServer* pServer)
|
||||
{
|
||||
CNetBan::Init(pConsole, pStorage);
|
||||
|
||||
|
@ -1609,7 +1609,7 @@ void CServer::RegisterCommands()
|
|||
Console()->Chain("console_output_level", ConchainConsoleOutputLevelUpdate, this);
|
||||
|
||||
// register console commands in sub parts
|
||||
m_ServerBan.Init(Console(), Storage(), this);
|
||||
m_ServerBan.InitServerBan(Console(), Storage(), this);
|
||||
m_pGameServer->OnConsoleInit();
|
||||
}
|
||||
|
||||
|
|
|
@ -50,10 +50,10 @@ class CServerBan : public CNetBan
|
|||
public:
|
||||
class CServer *Server() const { return m_pServer; }
|
||||
|
||||
void Init(class IConsole *pConsole, class IStorage *pStorage, class CServer* pServer);
|
||||
void InitServerBan(class IConsole *pConsole, class IStorage *pStorage, class CServer* pServer);
|
||||
|
||||
int BanAddr(const NETADDR *pAddr, int Seconds, const char *pReason);
|
||||
int BanRange(const CNetRange *pRange, int Seconds, const char *pReason);
|
||||
virtual int BanAddr(const NETADDR *pAddr, int Seconds, const char *pReason);
|
||||
virtual int BanRange(const CNetRange *pRange, int Seconds, const char *pReason);
|
||||
|
||||
static void ConBanExt(class IConsole::IResult *pResult, void *pUser);
|
||||
};
|
||||
|
|
|
@ -16,21 +16,21 @@
|
|||
|
||||
const char *CConsole::CResult::GetString(unsigned Index)
|
||||
{
|
||||
if (Index < 0 || Index >= m_NumArgs)
|
||||
if (Index >= m_NumArgs)
|
||||
return "";
|
||||
return m_apArgs[Index];
|
||||
}
|
||||
|
||||
int CConsole::CResult::GetInteger(unsigned Index)
|
||||
{
|
||||
if (Index < 0 || Index >= m_NumArgs)
|
||||
if (Index >= m_NumArgs)
|
||||
return 0;
|
||||
return str_toint(m_apArgs[Index]);
|
||||
}
|
||||
|
||||
float CConsole::CResult::GetFloat(unsigned Index)
|
||||
{
|
||||
if (Index < 0 || Index >= m_NumArgs)
|
||||
if (Index >= m_NumArgs)
|
||||
return 0.0f;
|
||||
return str_tofloat(m_apArgs[Index]);
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ int CConsole::ParseStart(CResult *pResult, const char *pString, int Length)
|
|||
if(Length < Len)
|
||||
Len = Length;
|
||||
|
||||
str_copy(pResult->m_aStringStorage, pString, Length);
|
||||
str_copy(pResult->m_aStringStorage, pString, Len);
|
||||
pStr = pResult->m_aStringStorage;
|
||||
|
||||
// get command
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include <engine/storage.h>
|
||||
|
||||
#include <versionsrv/versionsrv.h>
|
||||
#include <versionsrv/mapversions.h>
|
||||
|
||||
#include "datafile.h"
|
||||
#include "memheap.h"
|
||||
|
|
|
@ -170,7 +170,7 @@ public:
|
|||
class IStorage *Storage() const { return m_pStorage; }
|
||||
|
||||
virtual ~CNetBan() {}
|
||||
virtual void Init(class IConsole *pConsole, class IStorage *pStorage);
|
||||
void Init(class IConsole *pConsole, class IStorage *pStorage);
|
||||
void Update();
|
||||
|
||||
virtual int BanAddr(const NETADDR *pAddr, int Seconds, const char *pReason);
|
||||
|
|
|
@ -195,13 +195,14 @@ int CSnapshotDelta::CreateDelta(CSnapshot *pFrom, CSnapshot *pTo, void *pDstData
|
|||
|
||||
// fetch previous indices
|
||||
// we do this as a separate pass because it helps the cache
|
||||
for(i = 0; i < pTo->NumItems(); i++)
|
||||
const int NumItems = pTo->NumItems();
|
||||
for(i = 0; i < NumItems; i++)
|
||||
{
|
||||
pCurItem = pTo->GetItem(i); // O(1) .. O(n)
|
||||
aPastIndecies[i] = GetItemIndexHashed(pCurItem->Key(), Hashlist); // O(n) .. O(n^n)
|
||||
}
|
||||
|
||||
for(i = 0; i < pTo->NumItems(); i++)
|
||||
for(i = 0; i < NumItems; i++)
|
||||
{
|
||||
// do delta
|
||||
ItemSize = pTo->GetItemSize(i); // O(1) .. O(n)
|
||||
|
@ -474,7 +475,7 @@ int CSnapshotStorage::Get(int Tick, int64 *pTagtime, CSnapshot **ppData, CSnapsh
|
|||
if(ppData)
|
||||
*ppData = pHolder->m_pSnap;
|
||||
if(ppAltData)
|
||||
*ppData = pHolder->m_pAltSnap;
|
||||
*ppAltData = pHolder->m_pAltSnap;
|
||||
return pHolder->m_SnapSize;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,17 +16,38 @@ public:
|
|||
FLAG_ALL=3
|
||||
};
|
||||
|
||||
class CSampleHandle
|
||||
{
|
||||
friend class ISound;
|
||||
int m_Id;
|
||||
public:
|
||||
CSampleHandle()
|
||||
: m_Id(-1)
|
||||
{}
|
||||
|
||||
bool IsValid() const { return Id() >= 0; }
|
||||
int Id() const { return m_Id; }
|
||||
};
|
||||
|
||||
virtual bool IsSoundEnabled() = 0;
|
||||
|
||||
virtual int LoadWV(const char *pFilename) = 0;
|
||||
virtual CSampleHandle LoadWV(const char *pFilename) = 0;
|
||||
|
||||
virtual void SetChannel(int ChannelID, float Volume, float Panning) = 0;
|
||||
virtual void SetListenerPos(float x, float y) = 0;
|
||||
|
||||
virtual int PlayAt(int ChannelID, int SampleID, int Flags, float x, float y) = 0;
|
||||
virtual int Play(int ChannelID, int SampleID, int Flags) = 0;
|
||||
virtual void Stop(int SampleID) = 0;
|
||||
virtual int PlayAt(int ChannelID, CSampleHandle Sound, int Flags, float x, float y) = 0;
|
||||
virtual int Play(int ChannelID, CSampleHandle Sound, int Flags) = 0;
|
||||
virtual void Stop(CSampleHandle Sound) = 0;
|
||||
virtual void StopAll() = 0;
|
||||
|
||||
protected:
|
||||
inline CSampleHandle CreateSampleHandle(int Index)
|
||||
{
|
||||
CSampleHandle Tex;
|
||||
Tex.m_Id = Index;
|
||||
return Tex;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -271,7 +271,7 @@ void CGameConsole::PossibleCommandsRenderCallback(const char *pStr, void *pUser)
|
|||
if(pInfo->m_EnumCount == pInfo->m_WantedCompletion)
|
||||
{
|
||||
float tw = pInfo->m_pSelf->TextRender()->TextWidth(pInfo->m_Cursor.m_pFont, pInfo->m_Cursor.m_FontSize, pStr, -1);
|
||||
pInfo->m_pSelf->Graphics()->TextureSet(-1);
|
||||
pInfo->m_pSelf->Graphics()->TextureClear();
|
||||
pInfo->m_pSelf->Graphics()->QuadsBegin();
|
||||
pInfo->m_pSelf->Graphics()->SetColor(229.0f/255.0f,185.0f/255.0f,4.0f/255.0f,0.85f);
|
||||
pInfo->m_pSelf->RenderTools()->DrawRoundRect(pInfo->m_Cursor.m_X-3, pInfo->m_Cursor.m_Y, tw+5, pInfo->m_Cursor.m_FontSize+4, pInfo->m_Cursor.m_FontSize/3);
|
||||
|
@ -351,7 +351,7 @@ void CGameConsole::OnRender()
|
|||
Graphics()->MapScreen(Screen.x, Screen.y, Screen.w, Screen.h);
|
||||
|
||||
// do console shadow
|
||||
Graphics()->TextureSet(-1);
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->QuadsBegin();
|
||||
IGraphics::CColorVertex Array[4] = {
|
||||
IGraphics::CColorVertex(0, 0,0,0, 0.5f),
|
||||
|
@ -375,7 +375,7 @@ void CGameConsole::OnRender()
|
|||
Graphics()->QuadsEnd();
|
||||
|
||||
// do small bar shadow
|
||||
Graphics()->TextureSet(-1);
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->QuadsBegin();
|
||||
Array[0] = IGraphics::CColorVertex(0, 0,0,0, 0.0f);
|
||||
Array[1] = IGraphics::CColorVertex(1, 0,0,0, 0.0f);
|
||||
|
|
|
@ -80,8 +80,7 @@ void CCountryFlags::LoadCountryflagsIndexfile()
|
|||
CountryFlag.m_Texture = Graphics()->LoadTextureRaw(Info.m_Width, Info.m_Height, Info.m_Format, Info.m_pData, Info.m_Format, 0);
|
||||
mem_free(Info.m_pData);
|
||||
}
|
||||
else
|
||||
CountryFlag.m_Texture = -1;
|
||||
|
||||
if(g_Config.m_Debug)
|
||||
{
|
||||
str_format(aBuf, sizeof(aBuf), "loaded country flag '%s'", aOrigin);
|
||||
|
@ -121,7 +120,6 @@ void CCountryFlags::OnInit()
|
|||
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "countryflags", "failed to load country flags. folder='countryflags/'");
|
||||
CCountryFlag DummyEntry;
|
||||
DummyEntry.m_CountryCode = -1;
|
||||
DummyEntry.m_Texture = -1;
|
||||
mem_zero(DummyEntry.m_aCountryCodeString, sizeof(DummyEntry.m_aCountryCodeString));
|
||||
m_aCountryFlags.add(DummyEntry);
|
||||
}
|
||||
|
@ -145,7 +143,7 @@ const CCountryFlags::CCountryFlag *CCountryFlags::GetByIndex(int Index) const
|
|||
void CCountryFlags::Render(int CountryCode, const vec4 *pColor, float x, float y, float w, float h)
|
||||
{
|
||||
const CCountryFlag *pFlag = GetByCountryCode(CountryCode);
|
||||
if(pFlag->m_Texture != -1)
|
||||
if(pFlag->m_Texture.IsValid())
|
||||
{
|
||||
Graphics()->TextureSet(pFlag->m_Texture);
|
||||
Graphics()->QuadsBegin();
|
||||
|
|
|
@ -13,7 +13,7 @@ public:
|
|||
{
|
||||
int m_CountryCode;
|
||||
char m_aCountryCodeString[8];
|
||||
int m_Texture;
|
||||
IGraphics::CTextureHandle m_Texture;
|
||||
|
||||
bool operator<(const CCountryFlag &Other) { return str_comp(m_aCountryCodeString, Other.m_aCountryCodeString) < 0; }
|
||||
};
|
||||
|
|
|
@ -115,7 +115,7 @@ void CDebugHud::RenderTuning()
|
|||
|
||||
y = y+Count*6;
|
||||
|
||||
Graphics()->TextureSet(-1);
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->BlendNormal();
|
||||
Graphics()->LinesBegin();
|
||||
float Height = 50.0f;
|
||||
|
|
|
@ -127,7 +127,7 @@ void CEmoticon::OnRender()
|
|||
|
||||
Graphics()->BlendNormal();
|
||||
|
||||
Graphics()->TextureSet(-1);
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->QuadsBegin();
|
||||
Graphics()->SetColor(0,0,0,0.3f);
|
||||
DrawCircle(Screen.w/2, Screen.h/2, 190.0f, 64);
|
||||
|
|
|
@ -20,7 +20,7 @@ void CFlow::DbgRender()
|
|||
|
||||
IGraphics::CLineItem Array[1024];
|
||||
int NumItems = 0;
|
||||
Graphics()->TextureSet(-1);
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->LinesBegin();
|
||||
for(int y = 0; y < m_Height; y++)
|
||||
for(int x = 0; x < m_Width; x++)
|
||||
|
|
|
@ -162,7 +162,7 @@ void CHud::RenderScoreHud()
|
|||
{
|
||||
// draw box
|
||||
Graphics()->BlendNormal();
|
||||
Graphics()->TextureSet(-1);
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->QuadsBegin();
|
||||
if(t == 0)
|
||||
Graphics()->SetColor(1.0f, 0.0f, 0.0f, 0.25f);
|
||||
|
@ -273,7 +273,7 @@ void CHud::RenderScoreHud()
|
|||
{
|
||||
// draw box
|
||||
Graphics()->BlendNormal();
|
||||
Graphics()->TextureSet(-1);
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->QuadsBegin();
|
||||
if(t == Local)
|
||||
Graphics()->SetColor(1.0f, 1.0f, 1.0f, 0.25f);
|
||||
|
@ -398,7 +398,7 @@ void CHud::RenderVoting()
|
|||
if(!m_pClient->m_pVoting->IsVoting() || Client()->State() == IClient::STATE_DEMOPLAYBACK)
|
||||
return;
|
||||
|
||||
Graphics()->TextureSet(-1);
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->QuadsBegin();
|
||||
Graphics()->SetColor(0,0,0,0.40f);
|
||||
RenderTools()->DrawRoundRect(-10, 60-2, 100+10+4+5, 46, 5.0f);
|
||||
|
@ -466,7 +466,7 @@ void CHud::RenderHealthAndAmmo(const CNetObj_Character *pCharacter)
|
|||
// render ammo
|
||||
if(pCharacter->m_Weapon == WEAPON_NINJA)
|
||||
{
|
||||
Graphics()->TextureSet(-1);
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->QuadsBegin();
|
||||
Graphics()->SetColor(0.8f, 0.8f, 0.8f, 0.5f);
|
||||
RenderTools()->DrawRoundRectExt(x,y+24, 118.0f, 10.0f, 0.0f, 0);
|
||||
|
@ -525,7 +525,7 @@ void CHud::RenderHealthAndAmmo(const CNetObj_Character *pCharacter)
|
|||
void CHud::RenderSpectatorHud()
|
||||
{
|
||||
// draw the box
|
||||
Graphics()->TextureSet(-1);
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->QuadsBegin();
|
||||
Graphics()->SetColor(0.0f, 0.0f, 0.0f, 0.4f);
|
||||
RenderTools()->DrawRoundRectExt(m_Width-180.0f, m_Height-15.0f, 180.0f, 15.0f, 5.0f, CUI::CORNER_TL);
|
||||
|
|
|
@ -213,7 +213,7 @@ void CItems::RenderLaser(const struct CNetObj_Laser *pCurrent)
|
|||
vec2 Out, Border;
|
||||
|
||||
Graphics()->BlendNormal();
|
||||
Graphics()->TextureSet(-1);
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->QuadsBegin();
|
||||
|
||||
//vec4 inner_color(0.15f,0.35f,0.75f,1.0f);
|
||||
|
|
|
@ -22,7 +22,7 @@ void CMapImages::OnMapLoad()
|
|||
for(int i = 0; i < m_Count; i++)
|
||||
{
|
||||
Graphics()->UnloadTexture(m_aTextures[i]);
|
||||
m_aTextures[i] = -1;
|
||||
m_aTextures[i] = IGraphics::CTextureHandle();
|
||||
}
|
||||
m_Count = 0;
|
||||
|
||||
|
@ -32,8 +32,6 @@ void CMapImages::OnMapLoad()
|
|||
// load new textures
|
||||
for(int i = 0; i < m_Count; i++)
|
||||
{
|
||||
m_aTextures[i] = 0;
|
||||
|
||||
CMapItemImage *pImg = (CMapItemImage *)pMap->GetItem(Start+i, 0, 0);
|
||||
if(pImg->m_External || (pImg->m_Version > 1 && pImg->m_Format != CImageInfo::FORMAT_RGB && pImg->m_Format != CImageInfo::FORMAT_RGBA))
|
||||
{
|
||||
|
@ -57,7 +55,7 @@ void CMapImages::OnMenuMapLoad(IMap *pMap)
|
|||
for(int i = 0; i < m_MenuCount; i++)
|
||||
{
|
||||
Graphics()->UnloadTexture(m_aMenuTextures[i]);
|
||||
m_aMenuTextures[i] = -1;
|
||||
m_aMenuTextures[i] = IGraphics::CTextureHandle();
|
||||
}
|
||||
m_MenuCount = 0;
|
||||
|
||||
|
@ -67,8 +65,6 @@ void CMapImages::OnMenuMapLoad(IMap *pMap)
|
|||
// load new textures
|
||||
for(int i = 0; i < m_MenuCount; i++)
|
||||
{
|
||||
m_aMenuTextures[i] = 0;
|
||||
|
||||
CMapItemImage *pImg = (CMapItemImage *)pMap->GetItem(Start+i, 0, 0);
|
||||
if(pImg->m_External || (pImg->m_Version > 1 && pImg->m_Format != CImageInfo::FORMAT_RGB && pImg->m_Format != CImageInfo::FORMAT_RGBA))
|
||||
{
|
||||
|
@ -86,7 +82,7 @@ void CMapImages::OnMenuMapLoad(IMap *pMap)
|
|||
}
|
||||
}
|
||||
|
||||
int CMapImages::Get(int Index) const
|
||||
IGraphics::CTextureHandle CMapImages::Get(int Index) const
|
||||
{
|
||||
if(Client()->State() == IClient::STATE_ONLINE || Client()->State() == IClient::STATE_DEMOPLAYBACK)
|
||||
return m_aTextures[Index];
|
||||
|
|
|
@ -6,14 +6,14 @@
|
|||
|
||||
class CMapImages : public CComponent
|
||||
{
|
||||
int m_aTextures[64];
|
||||
int m_aMenuTextures[64];
|
||||
IGraphics::CTextureHandle m_aTextures[64];
|
||||
IGraphics::CTextureHandle m_aMenuTextures[64];
|
||||
int m_Count;
|
||||
int m_MenuCount;
|
||||
public:
|
||||
CMapImages();
|
||||
|
||||
int Get(int Index) const;
|
||||
IGraphics::CTextureHandle Get(int Index) const;
|
||||
int Num() const;
|
||||
|
||||
virtual void OnMapLoad();
|
||||
|
|
|
@ -250,7 +250,7 @@ void CMapLayers::OnRender()
|
|||
{
|
||||
CMapItemLayerTilemap *pTMap = (CMapItemLayerTilemap *)pLayer;
|
||||
if(pTMap->m_Image == -1)
|
||||
Graphics()->TextureSet(-1);
|
||||
Graphics()->TextureClear();
|
||||
else
|
||||
Graphics()->TextureSet(m_pClient->m_pMapimages->Get(pTMap->m_Image));
|
||||
|
||||
|
@ -267,7 +267,7 @@ void CMapLayers::OnRender()
|
|||
{
|
||||
CMapItemLayerQuads *pQLayer = (CMapItemLayerQuads *)pLayer;
|
||||
if(pQLayer->m_Image == -1)
|
||||
Graphics()->TextureSet(-1);
|
||||
Graphics()->TextureClear();
|
||||
else
|
||||
Graphics()->TextureSet(m_pClient->m_pMapimages->Get(pQLayer->m_Image));
|
||||
|
||||
|
|
|
@ -916,7 +916,7 @@ void CMenus::RenderLoading()
|
|||
|
||||
Graphics()->BlendNormal();
|
||||
|
||||
Graphics()->TextureSet(-1);
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->QuadsBegin();
|
||||
Graphics()->SetColor(0,0,0,0.50f);
|
||||
RenderTools()->DrawRoundRect(x, y, w, h, 40.0f);
|
||||
|
@ -932,7 +932,7 @@ void CMenus::RenderLoading()
|
|||
r.h = h;
|
||||
UI()->DoLabel(&r, pCaption, 48.0f, 0, -1);
|
||||
|
||||
Graphics()->TextureSet(-1);
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->QuadsBegin();
|
||||
Graphics()->SetColor(1,1,1,0.75f);
|
||||
RenderTools()->DrawRoundRect(x+40, y+h-75, (w-80)*Percent, 25, 5.0f);
|
||||
|
@ -1100,6 +1100,8 @@ void CMenus::OnInit()
|
|||
Console()->Chain("add_friend", ConchainFriendlistUpdate, this);
|
||||
Console()->Chain("remove_friend", ConchainFriendlistUpdate, this);
|
||||
|
||||
m_TextureBlob = Graphics()->LoadTexture("blob.png", IStorage::TYPE_ALL, CImageInfo::FORMAT_AUTO, 0);
|
||||
|
||||
// setup load amount
|
||||
m_LoadCurrent = 0;
|
||||
m_LoadTotal = g_pData->m_NumImages;
|
||||
|
@ -1937,22 +1939,17 @@ void CMenus::OnRender()
|
|||
m_NumInputEvents = 0;
|
||||
}
|
||||
|
||||
static int gs_TextureBlob = -1;
|
||||
|
||||
void CMenus::RenderBackground()
|
||||
{
|
||||
//Graphics()->Clear(1,1,1);
|
||||
//render_sunrays(0,0);
|
||||
if(gs_TextureBlob == -1)
|
||||
gs_TextureBlob = Graphics()->LoadTexture("blob.png", IStorage::TYPE_ALL, CImageInfo::FORMAT_AUTO, 0);
|
||||
|
||||
|
||||
float sw = 300*Graphics()->ScreenAspect();
|
||||
float sh = 300;
|
||||
Graphics()->MapScreen(0, 0, sw, sh);
|
||||
|
||||
// render background color
|
||||
Graphics()->TextureSet(-1);
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->QuadsBegin();
|
||||
//vec4 bottom(gui_color.r*0.3f, gui_color.g*0.3f, gui_color.b*0.3f, 1.0f);
|
||||
//vec4 bottom(0, 0, 0, 1.0f);
|
||||
|
@ -1969,7 +1966,7 @@ void CMenus::RenderBackground()
|
|||
Graphics()->QuadsEnd();
|
||||
|
||||
// render the tiles
|
||||
Graphics()->TextureSet(-1);
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->QuadsBegin();
|
||||
float Size = 15.0f;
|
||||
float OffsetTime = fmod(Client()->LocalTime()*0.15f, 2.0f);
|
||||
|
@ -1983,7 +1980,7 @@ void CMenus::RenderBackground()
|
|||
Graphics()->QuadsEnd();
|
||||
|
||||
// render border fade
|
||||
Graphics()->TextureSet(gs_TextureBlob);
|
||||
Graphics()->TextureSet(m_TextureBlob);
|
||||
Graphics()->QuadsBegin();
|
||||
Graphics()->SetColor(0,0,0,0.5f);
|
||||
QuadItem = IGraphics::CQuadItem(-100, -100, sw+200, sh+200);
|
||||
|
|
|
@ -52,7 +52,7 @@ class CMenus : public CComponent
|
|||
int DoButton_MenuImage(const void *pID, const char *pText, int Checked, const CUIRect *pRect, const char *pImageName, float r=5.0f, float FontFactor=0.0f);
|
||||
int DoButton_MenuTab(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Corners);
|
||||
int DoButton_MenuTabTop(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Corners);
|
||||
int DoButton_Customize(const void *pID, int Texture, int SpriteID, const CUIRect *pRect, float ImageRatio);
|
||||
int DoButton_Customize(const void *pID, IGraphics::CTextureHandle Texture, int SpriteID, const CUIRect *pRect, float ImageRatio);
|
||||
|
||||
int DoButton_CheckBox_Common(const void *pID, const char *pText, const char *pBoxText, const CUIRect *pRect);
|
||||
int DoButton_CheckBox(const void *pID, const char *pText, int Checked, const CUIRect *pRect);
|
||||
|
@ -159,8 +159,8 @@ class CMenus : public CComponent
|
|||
struct CMenuImage
|
||||
{
|
||||
char m_aName[64];
|
||||
int m_OrgTexture;
|
||||
int m_GreyTexture;
|
||||
IGraphics::CTextureHandle m_OrgTexture;
|
||||
IGraphics::CTextureHandle m_GreyTexture;
|
||||
};
|
||||
array<CMenuImage> m_lMenuImages;
|
||||
|
||||
|
@ -435,6 +435,7 @@ class CMenus : public CComponent
|
|||
|
||||
static int PopupFilter(CMenus *pMenus, CUIRect View);
|
||||
|
||||
IGraphics::CTextureHandle m_TextureBlob;
|
||||
public:
|
||||
void RenderBackground();
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
|
|||
for(int i = 0; i < pInfo->m_NumTimelineMarkers; i++)
|
||||
{
|
||||
float Ratio = (pInfo->m_aTimelineMarkers[i]-pInfo->m_FirstTick) / (float)TotalTicks;
|
||||
Graphics()->TextureSet(-1);
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->QuadsBegin();
|
||||
Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
IGraphics::CQuadItem QuadItem(SeekBar.x + (SeekBar.w-10.0f)*Ratio, SeekBar.y, UI()->PixelSize(), SeekBar.h);
|
||||
|
|
|
@ -51,7 +51,7 @@ bool CMenusKeyBinder::OnInput(IInput::CEvent Event)
|
|||
static int const gs_aSelectionParts[6] = {SELECTION_BODY, SELECTION_TATTOO, SELECTION_DECORATION,
|
||||
SELECTION_HANDS, SELECTION_FEET, SELECTION_EYES};
|
||||
|
||||
int CMenus::DoButton_Customize(const void *pID, int Texture, int SpriteID, const CUIRect *pRect, float ImageRatio)
|
||||
int CMenus::DoButton_Customize(const void *pID, IGraphics::CTextureHandle Texture, int SpriteID, const CUIRect *pRect, float ImageRatio)
|
||||
{
|
||||
float Seconds = 0.6f; // 0.6 seconds for fade
|
||||
float *pFade = ButtonFade(pID, Seconds);
|
||||
|
@ -191,7 +191,7 @@ void CMenus::RenderHSLPicker(CUIRect Picker)
|
|||
|
||||
// marker
|
||||
vec2 Marker = vec2(Hue*UI()->Scale(), max(0.0f, 127-Lgt/2.0f)*UI()->Scale());
|
||||
Graphics()->TextureSet(-1);
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->QuadsBegin();
|
||||
Graphics()->SetColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
IGraphics::CQuadItem aMarker[2];
|
||||
|
@ -237,7 +237,7 @@ void CMenus::RenderHSLPicker(CUIRect Picker)
|
|||
}
|
||||
// bar
|
||||
Bar.VSplitLeft(256/2, &Bar, &Button);
|
||||
Graphics()->TextureSet(-1);
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->QuadsBegin();
|
||||
for(int v = 0; v < 256/2; v++)
|
||||
{
|
||||
|
@ -958,7 +958,7 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
|
|||
|
||||
for(int p = 0; p < NUM_SKINPARTS; p++)
|
||||
{
|
||||
int Tex = g_pData->m_aImages[IMAGE_NO_SKINPART].m_Id;
|
||||
IGraphics::CTextureHandle Tex = g_pData->m_aImages[IMAGE_NO_SKINPART].m_Id;
|
||||
int Sprite = -1;
|
||||
if(gs_apSkinVariables[p][0])
|
||||
{
|
||||
|
|
|
@ -43,7 +43,7 @@ void CMotd::OnRender()
|
|||
float y = 150.0f;
|
||||
|
||||
Graphics()->BlendNormal();
|
||||
Graphics()->TextureSet(-1);
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->QuadsBegin();
|
||||
Graphics()->SetColor(0,0,0,0.5f);
|
||||
RenderTools()->DrawRoundRect(x, y, w, h, 40.0f);
|
||||
|
|
|
@ -48,7 +48,7 @@ void CScoreboard::RenderGoals(float x, float y, float w)
|
|||
float h = 50.0f;
|
||||
|
||||
Graphics()->BlendNormal();
|
||||
Graphics()->TextureSet(-1);
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->QuadsBegin();
|
||||
Graphics()->SetColor(0,0,0,0.5f);
|
||||
RenderTools()->DrawRoundRect(x, y, w, h, 10.0f);
|
||||
|
@ -83,7 +83,7 @@ void CScoreboard::RenderSpectators(float x, float y, float w)
|
|||
|
||||
// background
|
||||
Graphics()->BlendNormal();
|
||||
Graphics()->TextureSet(-1);
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->QuadsBegin();
|
||||
Graphics()->SetColor(0,0,0,0.5f);
|
||||
RenderTools()->DrawRoundRect(x, y, w, h, 10.0f);
|
||||
|
@ -125,7 +125,7 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
|
|||
|
||||
// background
|
||||
Graphics()->BlendNormal();
|
||||
Graphics()->TextureSet(-1);
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->QuadsBegin();
|
||||
Graphics()->SetColor(0.0f, 0.0f, 0.0f, 0.5f);
|
||||
RenderTools()->DrawRoundRect(x, y, w, h, 17.0f);
|
||||
|
@ -228,7 +228,7 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
|
|||
// background so it's easy to find the local player or the followed one in spectator mode
|
||||
if(m_pClient->m_LocalClientID == pInfo->m_ClientID || (m_pClient->m_Snap.m_SpecInfo.m_Active && pInfo->m_ClientID == m_pClient->m_Snap.m_SpecInfo.m_SpectatorID))
|
||||
{
|
||||
Graphics()->TextureSet(-1);
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->QuadsBegin();
|
||||
Graphics()->SetColor(1.0f, 1.0f, 1.0f, 0.25f*ColorAlpha);
|
||||
RenderTools()->DrawRoundRect(x, y, w-20.0f, LineHeight, 15.0f);
|
||||
|
@ -319,7 +319,7 @@ void CScoreboard::RenderRecordingNotification(float x)
|
|||
|
||||
//draw the box
|
||||
Graphics()->BlendNormal();
|
||||
Graphics()->TextureSet(-1);
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->QuadsBegin();
|
||||
Graphics()->SetColor(0.0f, 0.0f, 0.0f, 0.4f);
|
||||
RenderTools()->DrawRoundRectExt(x, 0.0f, 180.0f, 50.0f, 15.0f, CUI::CORNER_B);
|
||||
|
|
|
@ -217,8 +217,6 @@ void CSkins::OnInit()
|
|||
{
|
||||
CSkinPart NoneSkinPart;
|
||||
str_copy(NoneSkinPart.m_aName, "", sizeof(NoneSkinPart.m_aName));
|
||||
NoneSkinPart.m_OrgTexture = -1;
|
||||
NoneSkinPart.m_ColorTexture = -1;
|
||||
NoneSkinPart.m_BloodColor = vec3(1.0f, 1.0f, 1.0f);
|
||||
m_aaSkinParts[p].add(NoneSkinPart);
|
||||
}
|
||||
|
@ -234,8 +232,6 @@ void CSkins::OnInit()
|
|||
{
|
||||
CSkinPart DummySkinPart;
|
||||
str_copy(DummySkinPart.m_aName, "dummy", sizeof(DummySkinPart.m_aName));
|
||||
DummySkinPart.m_OrgTexture = -1;
|
||||
DummySkinPart.m_ColorTexture = -1;
|
||||
DummySkinPart.m_BloodColor = vec3(1.0f, 1.0f, 1.0f);
|
||||
m_aaSkinParts[p].add(DummySkinPart);
|
||||
}
|
||||
|
|
|
@ -28,8 +28,8 @@ public:
|
|||
struct CSkinPart
|
||||
{
|
||||
char m_aName[24];
|
||||
int m_OrgTexture;
|
||||
int m_ColorTexture;
|
||||
IGraphics::CTextureHandle m_OrgTexture;
|
||||
IGraphics::CTextureHandle m_ColorTexture;
|
||||
vec3 m_BloodColor;
|
||||
|
||||
bool operator<(const CSkinPart &Other) { return str_comp_nocase(m_aName, Other.m_aName) < 0; }
|
||||
|
|
|
@ -24,7 +24,7 @@ static int LoadSoundsThread(void *pUser)
|
|||
{
|
||||
for(int i = 0; i < g_pData->m_aSounds[s].m_NumSounds; i++)
|
||||
{
|
||||
int Id = pData->m_pGameClient->Sound()->LoadWV(g_pData->m_aSounds[s].m_aSounds[i].m_pFilename);
|
||||
ISound::CSampleHandle Id = pData->m_pGameClient->Sound()->LoadWV(g_pData->m_aSounds[s].m_aSounds[i].m_pFilename);
|
||||
g_pData->m_aSounds[s].m_aSounds[i].m_Id = Id;
|
||||
}
|
||||
|
||||
|
@ -35,14 +35,14 @@ static int LoadSoundsThread(void *pUser)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int CSounds::GetSampleId(int SetId)
|
||||
ISound::CSampleHandle CSounds::GetSampleId(int SetId)
|
||||
{
|
||||
if(!g_Config.m_SndEnable || !Sound()->IsSoundEnabled() || m_WaitForSoundJob || SetId < 0 || SetId >= g_pData->m_NumSounds)
|
||||
return -1;
|
||||
return ISound::CSampleHandle();
|
||||
|
||||
CDataSoundset *pSet = &g_pData->m_aSounds[SetId];
|
||||
if(!pSet->m_NumSounds)
|
||||
return -1;
|
||||
return ISound::CSampleHandle();
|
||||
|
||||
if(pSet->m_NumSounds == 1)
|
||||
return pSet->m_aSounds[0].m_Id;
|
||||
|
@ -155,8 +155,8 @@ void CSounds::Play(int Chn, int SetId, float Vol)
|
|||
if(Chn == CHN_MUSIC && !g_Config.m_SndMusic)
|
||||
return;
|
||||
|
||||
int SampleId = GetSampleId(SetId);
|
||||
if(SampleId == -1)
|
||||
ISound::CSampleHandle SampleId = GetSampleId(SetId);
|
||||
if(!SampleId.IsValid())
|
||||
return;
|
||||
|
||||
int Flags = 0;
|
||||
|
@ -171,8 +171,8 @@ void CSounds::PlayAt(int Chn, int SetId, float Vol, vec2 Pos)
|
|||
if(Chn == CHN_MUSIC && !g_Config.m_SndMusic)
|
||||
return;
|
||||
|
||||
int SampleId = GetSampleId(SetId);
|
||||
if(SampleId == -1)
|
||||
ISound::CSampleHandle SampleId = GetSampleId(SetId);
|
||||
if(!SampleId.IsValid())
|
||||
return;
|
||||
|
||||
int Flags = 0;
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
/* If you are missing that file, acquire a complete release at teeworlds.com. */
|
||||
#ifndef GAME_CLIENT_COMPONENTS_SOUNDS_H
|
||||
#define GAME_CLIENT_COMPONENTS_SOUNDS_H
|
||||
|
||||
#include <engine/sound.h>
|
||||
#include <game/client/component.h>
|
||||
|
||||
class CSounds : public CComponent
|
||||
|
@ -20,7 +22,7 @@ class CSounds : public CComponent
|
|||
class CJob m_SoundJob;
|
||||
bool m_WaitForSoundJob;
|
||||
|
||||
int GetSampleId(int SetId);
|
||||
ISound::CSampleHandle GetSampleId(int SetId);
|
||||
|
||||
public:
|
||||
// sound channels
|
||||
|
|
|
@ -179,7 +179,7 @@ void CSpectator::OnRender()
|
|||
Graphics()->MapScreen(0, 0, Width, Height);
|
||||
|
||||
Graphics()->BlendNormal();
|
||||
Graphics()->TextureSet(-1);
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->QuadsBegin();
|
||||
Graphics()->SetColor(0.0f, 0.0f, 0.0f, 0.3f);
|
||||
RenderTools()->DrawRoundRect(Width/2.0f-300.0f, Height/2.0f-300.0f, 600.0f, 600.0f, 20.0f);
|
||||
|
@ -199,7 +199,7 @@ void CSpectator::OnRender()
|
|||
{
|
||||
if(m_pClient->m_Snap.m_SpecInfo.m_SpectatorID == SPEC_FREEVIEW)
|
||||
{
|
||||
Graphics()->TextureSet(-1);
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->QuadsBegin();
|
||||
Graphics()->SetColor(1.0f, 1.0f, 1.0f, 0.25f);
|
||||
RenderTools()->DrawRoundRect(Width/2.0f-280.0f, Height/2.0f-280.0f, 270.0f, 60.0f, 20.0f);
|
||||
|
@ -232,7 +232,7 @@ void CSpectator::OnRender()
|
|||
|
||||
if(m_pClient->m_Snap.m_SpecInfo.m_SpectatorID == i)
|
||||
{
|
||||
Graphics()->TextureSet(-1);
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->QuadsBegin();
|
||||
Graphics()->SetColor(1.0f, 1.0f, 1.0f, 0.25f);
|
||||
RenderTools()->DrawRoundRect(Width/2.0f+x-10.0f, Height/2.0f+y-10.0f, 270.0f, 60.0f, 20.0f);
|
||||
|
|
|
@ -50,8 +50,6 @@
|
|||
#include "components/spectator.h"
|
||||
#include "components/voting.h"
|
||||
|
||||
CGameClient g_GameClient;
|
||||
|
||||
// instanciate all systems
|
||||
static CKillMessages gs_KillMessages;
|
||||
static CCamera gs_Camera;
|
||||
|
@ -281,7 +279,7 @@ void CGameClient::OnInit()
|
|||
for(int i = 0; i < g_pData->m_NumImages; i++)
|
||||
{
|
||||
g_pData->m_aImages[i].m_Id = Graphics()->LoadTexture(g_pData->m_aImages[i].m_pFilename, IStorage::TYPE_ALL, CImageInfo::FORMAT_AUTO, 0);
|
||||
g_GameClient.m_pMenus->RenderLoading();
|
||||
m_pMenus->RenderLoading();
|
||||
}
|
||||
|
||||
OnReset();
|
||||
|
@ -359,10 +357,10 @@ void CGameClient::OnReset()
|
|||
{
|
||||
// clear out the invalid pointers
|
||||
m_LastNewPredictedTick = -1;
|
||||
mem_zero(&g_GameClient.m_Snap, sizeof(g_GameClient.m_Snap));
|
||||
mem_zero(&m_Snap, sizeof(m_Snap));
|
||||
|
||||
for(int i = 0; i < MAX_CLIENTS; i++)
|
||||
m_aClients[i].Reset();
|
||||
m_aClients[i].Reset(this);
|
||||
|
||||
for(int i = 0; i < m_All.m_Num; i++)
|
||||
m_All.m_paComponents[i]->OnReset();
|
||||
|
@ -420,12 +418,12 @@ void CGameClient::UpdatePositions()
|
|||
}
|
||||
|
||||
|
||||
static void Evolve(CNetObj_Character *pCharacter, int Tick)
|
||||
void CGameClient::EvolveCharacter(CNetObj_Character *pCharacter, int Tick)
|
||||
{
|
||||
CWorldCore TempWorld;
|
||||
CCharacterCore TempCore;
|
||||
mem_zero(&TempCore, sizeof(TempCore));
|
||||
TempCore.Init(&TempWorld, g_GameClient.Collision());
|
||||
TempCore.Init(&TempWorld, Collision());
|
||||
TempCore.Read(pCharacter);
|
||||
|
||||
while(pCharacter->m_Tick < Tick)
|
||||
|
@ -497,7 +495,7 @@ void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker)
|
|||
if(pUnpacker->Error())
|
||||
return;
|
||||
|
||||
g_GameClient.m_pItems->AddExtraProjectile(&Proj);
|
||||
m_pItems->AddExtraProjectile(&Proj);
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -687,7 +685,7 @@ void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker)
|
|||
// update friend state
|
||||
m_aClients[pMsg->m_ClientID].m_Friend = Friends()->IsFriend(m_aClients[pMsg->m_ClientID].m_aName, m_aClients[pMsg->m_ClientID].m_aClan, true);
|
||||
|
||||
m_aClients[pMsg->m_ClientID].UpdateRenderInfo(true);
|
||||
m_aClients[pMsg->m_ClientID].UpdateRenderInfo(this, true);
|
||||
|
||||
m_GameInfo.m_NumPlayers++;
|
||||
// calculate team-balance
|
||||
|
@ -718,7 +716,7 @@ void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker)
|
|||
if(m_aClients[pMsg->m_ClientID].m_Team != TEAM_SPECTATORS)
|
||||
m_GameInfo.m_aTeamSize[m_aClients[pMsg->m_ClientID].m_Team]--;
|
||||
|
||||
m_aClients[pMsg->m_ClientID].Reset();
|
||||
m_aClients[pMsg->m_ClientID].Reset(this);
|
||||
}
|
||||
else if(MsgId == NETMSGTYPE_SV_GAMEINFO && Client()->State() != IClient::STATE_DEMOPLAYBACK)
|
||||
{
|
||||
|
@ -760,7 +758,7 @@ void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker)
|
|||
if(m_aClients[pMsg->m_ClientID].m_Team != TEAM_SPECTATORS)
|
||||
m_GameInfo.m_aTeamSize[m_aClients[pMsg->m_ClientID].m_Team]++;
|
||||
|
||||
m_aClients[pMsg->m_ClientID].UpdateRenderInfo(false);
|
||||
m_aClients[pMsg->m_ClientID].UpdateRenderInfo(this, false);
|
||||
|
||||
if(pMsg->m_ClientID == m_LocalClientID)
|
||||
m_TeamCooldownTick = pMsg->m_CooldownTick;
|
||||
|
@ -841,32 +839,32 @@ void CGameClient::ProcessEvents()
|
|||
if(Item.m_Type == NETEVENTTYPE_DAMAGEIND)
|
||||
{
|
||||
CNetEvent_DamageInd *ev = (CNetEvent_DamageInd *)pData;
|
||||
g_GameClient.m_pEffects->DamageIndicator(vec2(ev->m_X, ev->m_Y), GetDirection(ev->m_Angle));
|
||||
m_pEffects->DamageIndicator(vec2(ev->m_X, ev->m_Y), GetDirection(ev->m_Angle));
|
||||
}
|
||||
else if(Item.m_Type == NETEVENTTYPE_EXPLOSION)
|
||||
{
|
||||
CNetEvent_Explosion *ev = (CNetEvent_Explosion *)pData;
|
||||
g_GameClient.m_pEffects->Explosion(vec2(ev->m_X, ev->m_Y));
|
||||
m_pEffects->Explosion(vec2(ev->m_X, ev->m_Y));
|
||||
}
|
||||
else if(Item.m_Type == NETEVENTTYPE_HAMMERHIT)
|
||||
{
|
||||
CNetEvent_HammerHit *ev = (CNetEvent_HammerHit *)pData;
|
||||
g_GameClient.m_pEffects->HammerHit(vec2(ev->m_X, ev->m_Y));
|
||||
m_pEffects->HammerHit(vec2(ev->m_X, ev->m_Y));
|
||||
}
|
||||
else if(Item.m_Type == NETEVENTTYPE_SPAWN)
|
||||
{
|
||||
CNetEvent_Spawn *ev = (CNetEvent_Spawn *)pData;
|
||||
g_GameClient.m_pEffects->PlayerSpawn(vec2(ev->m_X, ev->m_Y));
|
||||
m_pEffects->PlayerSpawn(vec2(ev->m_X, ev->m_Y));
|
||||
}
|
||||
else if(Item.m_Type == NETEVENTTYPE_DEATH)
|
||||
{
|
||||
CNetEvent_Death *ev = (CNetEvent_Death *)pData;
|
||||
g_GameClient.m_pEffects->PlayerDeath(vec2(ev->m_X, ev->m_Y), ev->m_ClientID);
|
||||
m_pEffects->PlayerDeath(vec2(ev->m_X, ev->m_Y), ev->m_ClientID);
|
||||
}
|
||||
else if(Item.m_Type == NETEVENTTYPE_SOUNDWORLD)
|
||||
{
|
||||
CNetEvent_SoundWorld *ev = (CNetEvent_SoundWorld *)pData;
|
||||
g_GameClient.m_pSounds->PlayAt(CSounds::CHN_WORLD, ev->m_SoundID, 1.0f, vec2(ev->m_X, ev->m_Y));
|
||||
m_pSounds->PlayAt(CSounds::CHN_WORLD, ev->m_SoundID, 1.0f, vec2(ev->m_X, ev->m_Y));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -897,7 +895,7 @@ void CGameClient::OnNewSnapshot()
|
|||
m_NewTick = true;
|
||||
|
||||
// clear out the invalid pointers
|
||||
mem_zero(&g_GameClient.m_Snap, sizeof(g_GameClient.m_Snap));
|
||||
mem_zero(&m_Snap, sizeof(m_Snap));
|
||||
|
||||
// secure snapshot
|
||||
{
|
||||
|
@ -1039,9 +1037,9 @@ void CGameClient::OnNewSnapshot()
|
|||
m_Snap.m_aCharacters[Item.m_ID].m_Prev = *((const CNetObj_Character *)pOld);
|
||||
|
||||
if(m_Snap.m_aCharacters[Item.m_ID].m_Prev.m_Tick)
|
||||
Evolve(&m_Snap.m_aCharacters[Item.m_ID].m_Prev, Client()->PrevGameTick());
|
||||
EvolveCharacter(&m_Snap.m_aCharacters[Item.m_ID].m_Prev, Client()->PrevGameTick());
|
||||
if(m_Snap.m_aCharacters[Item.m_ID].m_Cur.m_Tick)
|
||||
Evolve(&m_Snap.m_aCharacters[Item.m_ID].m_Cur, Client()->GameTick());
|
||||
EvolveCharacter(&m_Snap.m_aCharacters[Item.m_ID].m_Cur, Client()->GameTick());
|
||||
}
|
||||
|
||||
if(Item.m_ID != m_LocalClientID || Client()->State() == IClient::STATE_DEMOPLAYBACK)
|
||||
|
@ -1141,7 +1139,7 @@ void CGameClient::OnNewSnapshot()
|
|||
for(int i = 0; i < MAX_CLIENTS; ++i)
|
||||
{
|
||||
if(m_aClients[i].m_Active)
|
||||
m_aClients[i].UpdateRenderInfo(true);
|
||||
m_aClients[i].UpdateRenderInfo(this, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1238,9 +1236,9 @@ void CGameClient::OnPredict()
|
|||
if(!m_Snap.m_aCharacters[i].m_Active)
|
||||
continue;
|
||||
|
||||
g_GameClient.m_aClients[i].m_Predicted.Init(&World, Collision());
|
||||
World.m_apCharacters[i] = &g_GameClient.m_aClients[i].m_Predicted;
|
||||
g_GameClient.m_aClients[i].m_Predicted.Read(&m_Snap.m_aCharacters[i].m_Cur);
|
||||
m_aClients[i].m_Predicted.Init(&World, Collision());
|
||||
World.m_apCharacters[i] = &m_aClients[i].m_Predicted;
|
||||
m_aClients[i].m_Predicted.Read(&m_Snap.m_aCharacters[i].m_Cur);
|
||||
}
|
||||
|
||||
// predict
|
||||
|
@ -1323,7 +1321,7 @@ void CGameClient::OnActivateEditor()
|
|||
OnRelease();
|
||||
}
|
||||
|
||||
void CGameClient::CClientData::UpdateRenderInfo(bool UpdateSkinInfo)
|
||||
void CGameClient::CClientData::UpdateRenderInfo(CGameClient *pGameClient, bool UpdateSkinInfo)
|
||||
{
|
||||
// update skin info
|
||||
if(UpdateSkinInfo)
|
||||
|
@ -1335,19 +1333,19 @@ void CGameClient::CClientData::UpdateRenderInfo(bool UpdateSkinInfo)
|
|||
if(m_aaSkinPartNames[p][0] == 'x' && m_aaSkinPartNames[p][1] == '_')
|
||||
str_copy(m_aaSkinPartNames[p], "default", 24);
|
||||
|
||||
m_SkinPartIDs[p] = g_GameClient.m_pSkins->FindSkinPart(p, m_aaSkinPartNames[p]);
|
||||
m_SkinPartIDs[p] = pGameClient->m_pSkins->FindSkinPart(p, m_aaSkinPartNames[p]);
|
||||
if(m_SkinPartIDs[p] < 0)
|
||||
{
|
||||
m_SkinPartIDs[p] = g_GameClient.m_pSkins->Find("default");
|
||||
m_SkinPartIDs[p] = pGameClient->m_pSkins->Find("default");
|
||||
if(m_SkinPartIDs[p] < 0)
|
||||
m_SkinPartIDs[p] = 0;
|
||||
}
|
||||
|
||||
const CSkins::CSkinPart *pSkinPart = g_GameClient.m_pSkins->GetSkinPart(p, m_SkinPartIDs[p]);
|
||||
const CSkins::CSkinPart *pSkinPart = pGameClient->m_pSkins->GetSkinPart(p, m_SkinPartIDs[p]);
|
||||
if(m_aUseCustomColors[p])
|
||||
{
|
||||
m_SkinInfo.m_aTextures[p] = pSkinPart->m_ColorTexture;
|
||||
m_SkinInfo.m_aColors[p] = g_GameClient.m_pSkins->GetColorV4(m_aSkinPartColors[p], p==SKINPART_TATTOO);
|
||||
m_SkinInfo.m_aColors[p] = pGameClient->m_pSkins->GetColorV4(m_aSkinPartColors[p], p==SKINPART_TATTOO);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1360,18 +1358,18 @@ void CGameClient::CClientData::UpdateRenderInfo(bool UpdateSkinInfo)
|
|||
m_RenderInfo = m_SkinInfo;
|
||||
|
||||
// force team colors
|
||||
if(g_GameClient.m_GameInfo.m_GameFlags&GAMEFLAG_TEAMS)
|
||||
if(pGameClient->m_GameInfo.m_GameFlags&GAMEFLAG_TEAMS)
|
||||
{
|
||||
for(int p = 0; p < NUM_SKINPARTS; p++)
|
||||
{
|
||||
m_RenderInfo.m_aTextures[p] = g_GameClient.m_pSkins->GetSkinPart(p, m_SkinPartIDs[p])->m_ColorTexture;
|
||||
int ColorVal = g_GameClient.m_pSkins->GetTeamColor(m_aUseCustomColors[p], m_aSkinPartColors[p], m_Team, p);
|
||||
m_RenderInfo.m_aColors[p] = g_GameClient.m_pSkins->GetColorV4(ColorVal, p==SKINPART_TATTOO);
|
||||
m_RenderInfo.m_aTextures[p] = pGameClient->m_pSkins->GetSkinPart(p, m_SkinPartIDs[p])->m_ColorTexture;
|
||||
int ColorVal = pGameClient->m_pSkins->GetTeamColor(m_aUseCustomColors[p], m_aSkinPartColors[p], m_Team, p);
|
||||
m_RenderInfo.m_aColors[p] = pGameClient->m_pSkins->GetColorV4(ColorVal, p==SKINPART_TATTOO);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CGameClient::CClientData::Reset()
|
||||
void CGameClient::CClientData::Reset(CGameClient *pGameClient)
|
||||
{
|
||||
m_aName[0] = 0;
|
||||
m_aClan[0] = 0;
|
||||
|
@ -1386,10 +1384,10 @@ void CGameClient::CClientData::Reset()
|
|||
for(int p = 0; p < NUM_SKINPARTS; p++)
|
||||
{
|
||||
m_SkinPartIDs[p] = 0;
|
||||
m_SkinInfo.m_aTextures[p] = g_GameClient.m_pSkins->GetSkinPart(p, 0)->m_ColorTexture;
|
||||
m_SkinInfo.m_aTextures[p] = pGameClient->m_pSkins->GetSkinPart(p, 0)->m_ColorTexture;
|
||||
m_SkinInfo.m_aColors[p] = vec4(1.0f, 1.0f, 1.0f , 1.0f);
|
||||
}
|
||||
UpdateRenderInfo(false);
|
||||
UpdateRenderInfo(pGameClient, false);
|
||||
}
|
||||
|
||||
void CGameClient::DoEnterMessage(const char *pName, int Team)
|
||||
|
@ -1435,7 +1433,7 @@ void CGameClient::SendStartInfo()
|
|||
Msg.m_aUseCustomColors[p] = *gs_apUCCVariables[p];
|
||||
Msg.m_aSkinPartColors[p] = *gs_apColorVariables[p];
|
||||
}
|
||||
Client()->SendPackMsg(&Msg, MSGFLAG_VITAL);
|
||||
Client()->SendPackMsg(&Msg, MSGFLAG_VITAL|MSGFLAG_FLUSH);
|
||||
}
|
||||
|
||||
void CGameClient::SendKill()
|
||||
|
@ -1473,5 +1471,5 @@ void CGameClient::ConchainFriendUpdate(IConsole::IResult *pResult, void *pUserDa
|
|||
|
||||
IGameClient *CreateGameClient()
|
||||
{
|
||||
return &g_GameClient;
|
||||
return new CGameClient();
|
||||
}
|
||||
|
|
|
@ -61,6 +61,9 @@ class CGameClient : public IGameClient
|
|||
static void ConReadyChange(IConsole::IResult *pResult, void *pUserData);
|
||||
static void ConchainFriendUpdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
|
||||
|
||||
|
||||
void EvolveCharacter(CNetObj_Character *pCharacter, int Tick);
|
||||
|
||||
public:
|
||||
IKernel *Kernel() { return IInterface::Kernel(); }
|
||||
IEngine *Engine() const { return m_pEngine; }
|
||||
|
@ -183,8 +186,8 @@ public:
|
|||
bool m_ChatIgnore;
|
||||
bool m_Friend;
|
||||
|
||||
void UpdateRenderInfo(bool UpdateSkinInfo);
|
||||
void Reset();
|
||||
void UpdateRenderInfo(CGameClient *pGameClient, bool UpdateSkinInfo);
|
||||
void Reset(CGameClient *pGameClient);
|
||||
};
|
||||
|
||||
CClientData m_aClients[MAX_CLIENTS];
|
||||
|
|
|
@ -184,7 +184,7 @@ void CRenderTools::DrawRoundRect(float x, float y, float w, float h, float r)
|
|||
|
||||
void CRenderTools::DrawUIRect(const CUIRect *r, vec4 Color, int Corners, float Rounding)
|
||||
{
|
||||
Graphics()->TextureSet(-1);
|
||||
Graphics()->TextureClear();
|
||||
|
||||
// TODO: FIX US
|
||||
Graphics()->QuadsBegin();
|
||||
|
@ -220,7 +220,7 @@ void CRenderTools::RenderTee(CAnimState *pAnim, CTeeRenderInfo *pInfo, int Emote
|
|||
IGraphics::CQuadItem Item;
|
||||
|
||||
// draw decoration
|
||||
if(pInfo->m_aTextures[2] != -1)
|
||||
if(pInfo->m_aTextures[2].IsValid())
|
||||
{
|
||||
Graphics()->TextureSet(pInfo->m_aTextures[2]);
|
||||
Graphics()->QuadsBegin();
|
||||
|
@ -251,7 +251,7 @@ void CRenderTools::RenderTee(CAnimState *pAnim, CTeeRenderInfo *pInfo, int Emote
|
|||
Graphics()->QuadsEnd();
|
||||
|
||||
// draw tattoo
|
||||
if(pInfo->m_aTextures[1] != -1 && !OutLine)
|
||||
if(pInfo->m_aTextures[1].IsValid() && !OutLine)
|
||||
{
|
||||
Graphics()->TextureSet(pInfo->m_aTextures[1]);
|
||||
Graphics()->QuadsBegin();
|
||||
|
|
|
@ -3,26 +3,23 @@
|
|||
#ifndef GAME_CLIENT_RENDER_H
|
||||
#define GAME_CLIENT_RENDER_H
|
||||
|
||||
#include <engine/graphics.h>
|
||||
#include <base/vmath.h>
|
||||
#include <game/mapitems.h>
|
||||
#include "ui.h"
|
||||
|
||||
|
||||
class CTeeRenderInfo
|
||||
{
|
||||
public:
|
||||
CTeeRenderInfo()
|
||||
{
|
||||
for(int i = 0; i < 6; i++)
|
||||
{
|
||||
m_aTextures[i] = -1;
|
||||
m_aColors[i] = vec4(1,1,1,1);
|
||||
}
|
||||
m_Size = 1.0f;
|
||||
m_GotAirJump = 1;
|
||||
};
|
||||
|
||||
int m_aTextures[6];
|
||||
IGraphics::CTextureHandle m_aTextures[6];
|
||||
vec4 m_aColors[6];
|
||||
float m_Size;
|
||||
int m_GotAirJump;
|
||||
|
|
|
@ -23,10 +23,6 @@
|
|||
#include "auto_map.h"
|
||||
#include "editor.h"
|
||||
|
||||
int CEditor::ms_CheckerTexture;
|
||||
int CEditor::ms_BackgroundTexture;
|
||||
int CEditor::ms_CursorTexture;
|
||||
int CEditor::ms_EntitiesTexture;
|
||||
const void* CEditor::ms_pUiGotContext;
|
||||
|
||||
enum
|
||||
|
@ -36,7 +32,7 @@ enum
|
|||
|
||||
CEditorImage::~CEditorImage()
|
||||
{
|
||||
m_pEditor->Graphics()->UnloadTexture(m_TexID);
|
||||
m_pEditor->Graphics()->UnloadTexture(m_Texture);
|
||||
if(m_pData)
|
||||
{
|
||||
mem_free(m_pData);
|
||||
|
@ -574,7 +570,7 @@ void CEditor::RenderGrid(CLayerGroup *pGroup)
|
|||
int XGridOffset = XOffset % m_GridFactor;
|
||||
int YGridOffset = YOffset % m_GridFactor;
|
||||
|
||||
Graphics()->TextureSet(-1);
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->LinesBegin();
|
||||
|
||||
for(int i = 0; i < (int)w; i++)
|
||||
|
@ -599,7 +595,7 @@ void CEditor::RenderGrid(CLayerGroup *pGroup)
|
|||
Graphics()->LinesEnd();
|
||||
}
|
||||
|
||||
void CEditor::RenderBackground(CUIRect View, int Texture, float Size, float Brightness)
|
||||
void CEditor::RenderBackground(CUIRect View, IGraphics::CTextureHandle Texture, float Size, float Brightness)
|
||||
{
|
||||
Graphics()->TextureSet(Texture);
|
||||
Graphics()->BlendNormal();
|
||||
|
@ -1415,7 +1411,7 @@ void CEditor::DoQuadPoint(CQuad *pQuad, int QuadIndex, int V)
|
|||
Graphics()->QuadsDraw(&QuadItem, 1);
|
||||
}
|
||||
|
||||
void CEditor::DoQuadEnvelopes(CQuad *pQuad, int Index, int TexID)
|
||||
void CEditor::DoQuadEnvelopes(CQuad *pQuad, int Index, IGraphics::CTextureHandle Texture)
|
||||
{
|
||||
CEnvelope *pEnvelope = 0x0;
|
||||
if(pQuad->m_PosEnv >= 0 && pQuad->m_PosEnv < m_Map.m_lEnvelopes.size())
|
||||
|
@ -1427,7 +1423,7 @@ void CEditor::DoQuadEnvelopes(CQuad *pQuad, int Index, int TexID)
|
|||
CPoint *pPoints = pQuad->m_aPoints;
|
||||
|
||||
//Draw Lines
|
||||
Graphics()->TextureSet(-1);
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->LinesBegin();
|
||||
Graphics()->SetColor(80.0f/255, 150.0f/255, 230.f/255, 0.5f);
|
||||
for(int i = 0; i < pEnvelope->m_lPoints.size()-1; i++)
|
||||
|
@ -1449,7 +1445,7 @@ void CEditor::DoQuadEnvelopes(CQuad *pQuad, int Index, int TexID)
|
|||
//Draw Quads
|
||||
for(int i = 0; i < pEnvelope->m_lPoints.size(); i++)
|
||||
{
|
||||
Graphics()->TextureSet(TexID);
|
||||
Graphics()->TextureSet(Texture);
|
||||
Graphics()->QuadsBegin();
|
||||
|
||||
//Calc Env Position
|
||||
|
@ -1500,7 +1496,7 @@ void CEditor::DoQuadEnvelopes(CQuad *pQuad, int Index, int TexID)
|
|||
|
||||
Graphics()->QuadsEnd();
|
||||
|
||||
Graphics()->TextureSet(-1);
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->QuadsBegin();
|
||||
DoQuadEnvPoint(pQuad, Index, i);
|
||||
Graphics()->QuadsEnd();
|
||||
|
@ -1698,7 +1694,7 @@ void CEditor::DoMapEditor(CUIRect View, CUIRect ToolBar)
|
|||
if(t)
|
||||
{
|
||||
m_TilesetPicker.m_Image = t->m_Image;
|
||||
m_TilesetPicker.m_TexID = t->m_TexID;
|
||||
m_TilesetPicker.m_Texture = t->m_Texture;
|
||||
m_TilesetPicker.Render();
|
||||
if(m_ShowTileInfo)
|
||||
m_TilesetPicker.ShowInfo();
|
||||
|
@ -1743,7 +1739,7 @@ void CEditor::DoMapEditor(CUIRect View, CUIRect ToolBar)
|
|||
IGraphics::CLineItem(w, 0, w, h),
|
||||
IGraphics::CLineItem(w, h, 0, h),
|
||||
IGraphics::CLineItem(0, h, 0, 0)};
|
||||
Graphics()->TextureSet(-1);
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->LinesBegin();
|
||||
Graphics()->LinesDraw(Array, 4);
|
||||
Graphics()->LinesEnd();
|
||||
|
@ -1907,7 +1903,7 @@ void CEditor::DoMapEditor(CUIRect View, CUIRect ToolBar)
|
|||
IGraphics::CLineItem(w, 0, w, h),
|
||||
IGraphics::CLineItem(w, h, 0, h),
|
||||
IGraphics::CLineItem(0, h, 0, 0)};
|
||||
Graphics()->TextureSet(-1);
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->LinesBegin();
|
||||
Graphics()->LinesDraw(Array, 4);
|
||||
Graphics()->LinesEnd();
|
||||
|
@ -1934,7 +1930,7 @@ void CEditor::DoMapEditor(CUIRect View, CUIRect ToolBar)
|
|||
if(!m_ShowEnvelopePreview)
|
||||
m_ShowEnvelopePreview = 2;
|
||||
|
||||
Graphics()->TextureSet(-1);
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->QuadsBegin();
|
||||
for(int i = 0; i < pLayer->m_lQuads.size(); i++)
|
||||
{
|
||||
|
@ -1988,7 +1984,7 @@ void CEditor::DoMapEditor(CUIRect View, CUIRect ToolBar)
|
|||
CLayerGroup *g = m_Map.m_pGameGroup;
|
||||
g->MapScreen();
|
||||
|
||||
Graphics()->TextureSet(-1);
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->LinesBegin();
|
||||
|
||||
CUIRect r;
|
||||
|
@ -2014,7 +2010,7 @@ void CEditor::DoMapEditor(CUIRect View, CUIRect ToolBar)
|
|||
CLayerGroup *g = m_Map.m_pGameGroup;
|
||||
g->MapScreen();
|
||||
|
||||
Graphics()->TextureSet(-1);
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->LinesBegin();
|
||||
|
||||
float aLastPoints[4];
|
||||
|
@ -2096,14 +2092,14 @@ void CEditor::DoMapEditor(CUIRect View, CUIRect ToolBar)
|
|||
GetSelectedGroup()->MapScreen();
|
||||
|
||||
CLayerQuads *pLayer = (CLayerQuads*)GetSelectedLayer(0);
|
||||
int TexID = -1;
|
||||
IGraphics::CTextureHandle Texture;
|
||||
if(pLayer->m_Image >= 0 && pLayer->m_Image < m_Map.m_lImages.size())
|
||||
TexID = m_Map.m_lImages[pLayer->m_Image]->m_TexID;
|
||||
Texture = m_Map.m_lImages[pLayer->m_Image]->m_Texture;
|
||||
|
||||
for(int i = 0; i < pLayer->m_lQuads.size(); i++)
|
||||
{
|
||||
if((m_ShowEnvelopePreview == 1 && pLayer->m_lQuads[i].m_PosEnv == m_SelectedEnvelope) || m_ShowEnvelopePreview == 2)
|
||||
DoQuadEnvelopes(&pLayer->m_lQuads[i], i, TexID);
|
||||
DoQuadEnvelopes(&pLayer->m_lQuads[i], i, Texture);
|
||||
}
|
||||
|
||||
m_ShowEnvelopePreview = 0;
|
||||
|
@ -2299,8 +2295,6 @@ void CEditor::RenderLayers(CUIRect ToolBox, CUIRect ToolBar, CUIRect View)
|
|||
if(Input()->KeyPresses(KEY_MOUSE_WHEEL_DOWN))
|
||||
s_ScrollValue = clamp(s_ScrollValue + 1.0f/ScrollNum, 0.0f, 1.0f);
|
||||
}
|
||||
else
|
||||
ScrollNum = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2434,7 +2428,8 @@ void CEditor::ReplaceImage(const char *pFileName, int StorageType, void *pUser)
|
|||
|
||||
CEditorImage *pImg = pEditor->m_Map.m_lImages[pEditor->m_SelectedImage];
|
||||
int External = pImg->m_External;
|
||||
pEditor->Graphics()->UnloadTexture(pImg->m_TexID);
|
||||
pEditor->Graphics()->UnloadTexture(pImg->m_Texture);
|
||||
pImg->m_Texture = IGraphics::CTextureHandle();
|
||||
if(pImg->m_pData)
|
||||
{
|
||||
mem_free(pImg->m_pData);
|
||||
|
@ -2444,7 +2439,7 @@ void CEditor::ReplaceImage(const char *pFileName, int StorageType, void *pUser)
|
|||
pImg->m_External = External;
|
||||
pEditor->ExtractName(pFileName, pImg->m_aName, sizeof(pImg->m_aName));
|
||||
pImg->m_AutoMapper.Load(pImg->m_aName);
|
||||
pImg->m_TexID = pEditor->Graphics()->LoadTextureRaw(ImgInfo.m_Width, ImgInfo.m_Height, ImgInfo.m_Format, ImgInfo.m_pData, CImageInfo::FORMAT_AUTO, 0);
|
||||
pImg->m_Texture = pEditor->Graphics()->LoadTextureRaw(ImgInfo.m_Width, ImgInfo.m_Height, ImgInfo.m_Format, ImgInfo.m_pData, CImageInfo::FORMAT_AUTO, 0);
|
||||
ImgInfo.m_pData = 0;
|
||||
pEditor->SortImages();
|
||||
for(int i = 0; i < pEditor->m_Map.m_lImages.size(); ++i)
|
||||
|
@ -2473,7 +2468,7 @@ void CEditor::AddImage(const char *pFileName, int StorageType, void *pUser)
|
|||
|
||||
CEditorImage *pImg = new CEditorImage(pEditor);
|
||||
*pImg = ImgInfo;
|
||||
pImg->m_TexID = pEditor->Graphics()->LoadTextureRaw(ImgInfo.m_Width, ImgInfo.m_Height, ImgInfo.m_Format, ImgInfo.m_pData, CImageInfo::FORMAT_AUTO, 0);
|
||||
pImg->m_Texture = pEditor->Graphics()->LoadTextureRaw(ImgInfo.m_Width, ImgInfo.m_Height, ImgInfo.m_Format, ImgInfo.m_pData, CImageInfo::FORMAT_AUTO, 0);
|
||||
ImgInfo.m_pData = 0;
|
||||
pImg->m_External = 1; // external by default
|
||||
str_copy(pImg->m_aName, aBuf, sizeof(pImg->m_aName));
|
||||
|
@ -2622,8 +2617,6 @@ void CEditor::RenderImages(CUIRect ToolBox, CUIRect ToolBar, CUIRect View)
|
|||
if(Input()->KeyPresses(KEY_MOUSE_WHEEL_DOWN))
|
||||
s_ScrollValue = clamp(s_ScrollValue + 1.0f/ScrollNum, 0.0f, 1.0f);
|
||||
}
|
||||
else
|
||||
ScrollNum = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2696,7 +2689,7 @@ void CEditor::RenderImages(CUIRect ToolBox, CUIRect ToolBar, CUIRect View)
|
|||
float Max = (float)(max(m_Map.m_lImages[i]->m_Width, m_Map.m_lImages[i]->m_Height));
|
||||
r.w *= m_Map.m_lImages[i]->m_Width/Max;
|
||||
r.h *= m_Map.m_lImages[i]->m_Height/Max;
|
||||
Graphics()->TextureSet(m_Map.m_lImages[i]->m_TexID);
|
||||
Graphics()->TextureSet(m_Map.m_lImages[i]->m_Texture);
|
||||
Graphics()->BlendNormal();
|
||||
Graphics()->WrapClamp();
|
||||
Graphics()->QuadsBegin();
|
||||
|
@ -2711,7 +2704,7 @@ void CEditor::RenderImages(CUIRect ToolBox, CUIRect ToolBar, CUIRect View)
|
|||
ToolBox.HSplitTop(5.0f, &Slot, &ToolBox);
|
||||
ImageCur += 5.0f;
|
||||
IGraphics::CLineItem LineItem(Slot.x, Slot.y+Slot.h/2, Slot.x+Slot.w, Slot.y+Slot.h/2);
|
||||
Graphics()->TextureSet(-1);
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->LinesBegin();
|
||||
Graphics()->LinesDraw(&LineItem, 1);
|
||||
Graphics()->LinesEnd();
|
||||
|
@ -3209,10 +3202,10 @@ void CEditor::RenderEnvelopeEditor(CUIRect View)
|
|||
ShowColorBar = true;
|
||||
View.HSplitTop(20.0f, &ColorBar, &View);
|
||||
ColorBar.Margin(2.0f, &ColorBar);
|
||||
RenderBackground(ColorBar, ms_CheckerTexture, 16.0f, 1.0f);
|
||||
RenderBackground(ColorBar, m_CheckerTexture, 16.0f, 1.0f);
|
||||
}
|
||||
|
||||
RenderBackground(View, ms_CheckerTexture, 32.0f, 0.1f);
|
||||
RenderBackground(View, m_CheckerTexture, 32.0f, 0.1f);
|
||||
|
||||
if(pEnvelope)
|
||||
{
|
||||
|
@ -3311,7 +3304,7 @@ void CEditor::RenderEnvelopeEditor(CUIRect View)
|
|||
// render lines
|
||||
{
|
||||
UI()->ClipEnable(&View);
|
||||
Graphics()->TextureSet(-1);
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->LinesBegin();
|
||||
for(int c = 0; c < pEnvelope->m_Channels; c++)
|
||||
{
|
||||
|
@ -3371,7 +3364,7 @@ void CEditor::RenderEnvelopeEditor(CUIRect View)
|
|||
// render colorbar
|
||||
if(ShowColorBar)
|
||||
{
|
||||
Graphics()->TextureSet(-1);
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->QuadsBegin();
|
||||
for(int i = 0; i < pEnvelope->m_lPoints.size()-1; i++)
|
||||
{
|
||||
|
@ -3410,7 +3403,7 @@ void CEditor::RenderEnvelopeEditor(CUIRect View)
|
|||
{
|
||||
int CurrentValue = 0, CurrentTime = 0;
|
||||
|
||||
Graphics()->TextureSet(-1);
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->QuadsBegin();
|
||||
for(int c = 0; c < pEnvelope->m_Channels; c++)
|
||||
{
|
||||
|
@ -3660,7 +3653,7 @@ void CEditor::Render()
|
|||
--m_EditBoxActive;
|
||||
|
||||
// render checker
|
||||
RenderBackground(View, ms_CheckerTexture, 32.0f, 1.0f);
|
||||
RenderBackground(View, m_CheckerTexture, 32.0f, 1.0f);
|
||||
|
||||
CUIRect MenuBar, CModeBar, ToolBar, StatusBar, EnvelopeEditor, ToolBox;
|
||||
m_ShowPicker = Input()->KeyPressed(KEY_SPACE) != 0 && m_Dialog == DIALOG_NONE;
|
||||
|
@ -3713,17 +3706,17 @@ void CEditor::Render()
|
|||
if(m_GuiActive)
|
||||
{
|
||||
float Brightness = 0.25f;
|
||||
RenderBackground(MenuBar, ms_BackgroundTexture, 128.0f, Brightness*0);
|
||||
RenderBackground(MenuBar, m_BackgroundTexture, 128.0f, Brightness*0);
|
||||
MenuBar.Margin(2.0f, &MenuBar);
|
||||
|
||||
RenderBackground(ToolBox, ms_BackgroundTexture, 128.0f, Brightness);
|
||||
RenderBackground(ToolBox, m_BackgroundTexture, 128.0f, Brightness);
|
||||
ToolBox.Margin(2.0f, &ToolBox);
|
||||
|
||||
RenderBackground(ToolBar, ms_BackgroundTexture, 128.0f, Brightness);
|
||||
RenderBackground(ToolBar, m_BackgroundTexture, 128.0f, Brightness);
|
||||
ToolBar.Margin(2.0f, &ToolBar);
|
||||
ToolBar.VSplitLeft(100.0f, &CModeBar, &ToolBar);
|
||||
|
||||
RenderBackground(StatusBar, ms_BackgroundTexture, 128.0f, Brightness);
|
||||
RenderBackground(StatusBar, m_BackgroundTexture, 128.0f, Brightness);
|
||||
StatusBar.Margin(2.0f, &StatusBar);
|
||||
|
||||
// do the toolbar
|
||||
|
@ -3732,7 +3725,7 @@ void CEditor::Render()
|
|||
|
||||
if(m_ShowEnvelopeEditor)
|
||||
{
|
||||
RenderBackground(EnvelopeEditor, ms_BackgroundTexture, 128.0f, Brightness);
|
||||
RenderBackground(EnvelopeEditor, m_BackgroundTexture, 128.0f, Brightness);
|
||||
EnvelopeEditor.Margin(2.0f, &EnvelopeEditor);
|
||||
}
|
||||
}
|
||||
|
@ -3800,7 +3793,7 @@ void CEditor::Render()
|
|||
// render butt ugly mouse cursor
|
||||
float mx = UI()->MouseX();
|
||||
float my = UI()->MouseY();
|
||||
Graphics()->TextureSet(ms_CursorTexture);
|
||||
Graphics()->TextureSet(m_CursorTexture);
|
||||
Graphics()->QuadsBegin();
|
||||
if(ms_pUiGotContext == UI()->HotItem())
|
||||
Graphics()->SetColor(1,0,0,1);
|
||||
|
@ -3816,7 +3809,7 @@ void CEditor::Reset(bool CreateDefault)
|
|||
|
||||
// create default layers
|
||||
if(CreateDefault)
|
||||
m_Map.CreateDefault(ms_EntitiesTexture);
|
||||
m_Map.CreateDefault(m_EntitiesTexture);
|
||||
|
||||
/*
|
||||
{
|
||||
|
@ -3906,7 +3899,7 @@ void CEditorMap::MakeGameLayer(CLayer *pLayer)
|
|||
{
|
||||
m_pGameLayer = (CLayerGame *)pLayer;
|
||||
m_pGameLayer->m_pEditor = m_pEditor;
|
||||
m_pGameLayer->m_TexID = m_pEditor->ms_EntitiesTexture;
|
||||
m_pGameLayer->m_Texture = m_pEditor->m_EntitiesTexture;
|
||||
}
|
||||
|
||||
void CEditorMap::MakeGameGroup(CLayerGroup *pGroup)
|
||||
|
@ -3932,7 +3925,7 @@ void CEditorMap::Clean()
|
|||
m_Modified = false;
|
||||
}
|
||||
|
||||
void CEditorMap::CreateDefault(int EntitiesTexture)
|
||||
void CEditorMap::CreateDefault(IGraphics::CTextureHandle EntitiesTexture)
|
||||
{
|
||||
// add background
|
||||
CLayerGroup *pGroup = NewGroup();
|
||||
|
@ -3975,10 +3968,10 @@ void CEditor::Init()
|
|||
m_UI.SetGraphics(m_pGraphics, m_pTextRender);
|
||||
m_Map.m_pEditor = this;
|
||||
|
||||
ms_CheckerTexture = Graphics()->LoadTexture("editor/checker.png", IStorage::TYPE_ALL, CImageInfo::FORMAT_AUTO, 0);
|
||||
ms_BackgroundTexture = Graphics()->LoadTexture("editor/background.png", IStorage::TYPE_ALL, CImageInfo::FORMAT_AUTO, 0);
|
||||
ms_CursorTexture = Graphics()->LoadTexture("editor/cursor.png", IStorage::TYPE_ALL, CImageInfo::FORMAT_AUTO, 0);
|
||||
ms_EntitiesTexture = Graphics()->LoadTexture("editor/entities.png", IStorage::TYPE_ALL, CImageInfo::FORMAT_AUTO, 0);
|
||||
m_CheckerTexture = Graphics()->LoadTexture("editor/checker.png", IStorage::TYPE_ALL, CImageInfo::FORMAT_AUTO, 0);
|
||||
m_BackgroundTexture = Graphics()->LoadTexture("editor/background.png", IStorage::TYPE_ALL, CImageInfo::FORMAT_AUTO, 0);
|
||||
m_CursorTexture = Graphics()->LoadTexture("editor/cursor.png", IStorage::TYPE_ALL, CImageInfo::FORMAT_AUTO, 0);
|
||||
m_EntitiesTexture = Graphics()->LoadTexture("editor/entities.png", IStorage::TYPE_ALL, CImageInfo::FORMAT_AUTO, 0);
|
||||
|
||||
m_TilesetPicker.m_pEditor = this;
|
||||
m_TilesetPicker.MakePalette();
|
||||
|
|
|
@ -239,7 +239,6 @@ public:
|
|||
: m_AutoMapper(pEditor)
|
||||
{
|
||||
m_pEditor = pEditor;
|
||||
m_TexID = -1;
|
||||
m_aName[0] = 0;
|
||||
m_External = 0;
|
||||
m_Width = 0;
|
||||
|
@ -252,7 +251,7 @@ public:
|
|||
|
||||
void AnalyseTileFlags();
|
||||
|
||||
int m_TexID;
|
||||
IGraphics::CTextureHandle m_Texture;
|
||||
int m_External;
|
||||
char m_aName[128];
|
||||
unsigned char m_aTileFlags[256];
|
||||
|
@ -359,7 +358,7 @@ public:
|
|||
}
|
||||
|
||||
void Clean();
|
||||
void CreateDefault(int EntitiesTexture);
|
||||
void CreateDefault(IGraphics::CTextureHandle EntitiesTexture);
|
||||
|
||||
// io
|
||||
int Save(class IStorage *pStorage, const char *pFilename);
|
||||
|
@ -430,7 +429,7 @@ public:
|
|||
|
||||
void GetSize(float *w, float *h) { *w = m_Width*32.0f; *h = m_Height*32.0f; }
|
||||
|
||||
int m_TexID;
|
||||
IGraphics::CTextureHandle m_Texture;
|
||||
int m_Game;
|
||||
int m_Image;
|
||||
int m_Width;
|
||||
|
@ -564,11 +563,6 @@ public:
|
|||
m_SelectedQuadEnvelope = -1;
|
||||
m_SelectedEnvelopePoint = -1;
|
||||
|
||||
ms_CheckerTexture = 0;
|
||||
ms_BackgroundTexture = 0;
|
||||
ms_CursorTexture = 0;
|
||||
ms_EntitiesTexture = 0;
|
||||
|
||||
ms_pUiGotContext = 0;
|
||||
}
|
||||
|
||||
|
@ -694,10 +688,10 @@ public:
|
|||
int m_SelectedQuadEnvelope;
|
||||
int m_SelectedImage;
|
||||
|
||||
static int ms_CheckerTexture;
|
||||
static int ms_BackgroundTexture;
|
||||
static int ms_CursorTexture;
|
||||
static int ms_EntitiesTexture;
|
||||
IGraphics::CTextureHandle m_CheckerTexture;
|
||||
IGraphics::CTextureHandle m_BackgroundTexture;
|
||||
IGraphics::CTextureHandle m_CursorTexture;
|
||||
IGraphics::CTextureHandle m_EntitiesTexture;
|
||||
|
||||
CLayerGroup m_Brush;
|
||||
CLayerTiles m_TilesetPicker;
|
||||
|
@ -724,7 +718,7 @@ public:
|
|||
|
||||
int DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrSize, float FontSize, float *Offset, bool Hidden=false, int Corners=CUI::CORNER_ALL);
|
||||
|
||||
void RenderBackground(CUIRect View, int Texture, float Size, float Brightness);
|
||||
void RenderBackground(CUIRect View, IGraphics::CTextureHandle Texture, float Size, float Brightness);
|
||||
|
||||
void RenderGrid(CLayerGroup *pGroup);
|
||||
|
||||
|
@ -761,7 +755,7 @@ public:
|
|||
|
||||
vec4 ButtonColorMul(const void *pID);
|
||||
|
||||
void DoQuadEnvelopes(CQuad *pQuad, int Index, int TexID = -1);
|
||||
void DoQuadEnvelopes(CQuad *pQuad, int Index, IGraphics::CTextureHandle Texture = IGraphics::CTextureHandle());
|
||||
void DoQuadEnvPoint(CQuad *pQuad, int QIndex, int pIndex);
|
||||
void DoQuadPoint(CQuad *pQuad, int QuadIndex, int v);
|
||||
|
||||
|
|
|
@ -483,7 +483,7 @@ int CEditorMap::Load(class IStorage *pStorage, const char *pFileName, int Storag
|
|||
if(m_pEditor->Graphics()->LoadPNG(&ImgInfo, aBuf, IStorage::TYPE_ALL))
|
||||
{
|
||||
*pImg = ImgInfo;
|
||||
pImg->m_TexID = m_pEditor->Graphics()->LoadTextureRaw(ImgInfo.m_Width, ImgInfo.m_Height, ImgInfo.m_Format, ImgInfo.m_pData, CImageInfo::FORMAT_AUTO, 0);
|
||||
pImg->m_Texture = m_pEditor->Graphics()->LoadTextureRaw(ImgInfo.m_Width, ImgInfo.m_Height, ImgInfo.m_Format, ImgInfo.m_pData, CImageInfo::FORMAT_AUTO, 0);
|
||||
ImgInfo.m_pData = 0;
|
||||
pImg->m_External = 1;
|
||||
}
|
||||
|
@ -499,7 +499,7 @@ int CEditorMap::Load(class IStorage *pStorage, const char *pFileName, int Storag
|
|||
void *pData = DataFile.GetData(pItem->m_ImageData);
|
||||
pImg->m_pData = mem_alloc(pImg->m_Width*pImg->m_Height*PixelSize, 1);
|
||||
mem_copy(pImg->m_pData, pData, pImg->m_Width*pImg->m_Height*PixelSize);
|
||||
pImg->m_TexID = m_pEditor->Graphics()->LoadTextureRaw(pImg->m_Width, pImg->m_Height, pImg->m_Format, pImg->m_pData, CImageInfo::FORMAT_AUTO, 0);
|
||||
pImg->m_Texture = m_pEditor->Graphics()->LoadTextureRaw(pImg->m_Width, pImg->m_Height, pImg->m_Format, pImg->m_pData, CImageInfo::FORMAT_AUTO, 0);
|
||||
}
|
||||
|
||||
// copy image name
|
||||
|
|
|
@ -23,9 +23,9 @@ CLayerQuads::~CLayerQuads()
|
|||
|
||||
void CLayerQuads::Render()
|
||||
{
|
||||
Graphics()->TextureSet(-1);
|
||||
Graphics()->TextureClear();
|
||||
if(m_Image >= 0 && m_Image < m_pEditor->m_Map.m_lImages.size())
|
||||
Graphics()->TextureSet(m_pEditor->m_Map.m_lImages[m_Image]->m_TexID);
|
||||
Graphics()->TextureSet(m_pEditor->m_Map.m_lImages[m_Image]->m_Texture);
|
||||
|
||||
m_pEditor->RenderTools()->RenderQuads(m_lQuads.base_ptr(), m_lQuads.size(), LAYERRENDERFLAG_OPAQUE|LAYERRENDERFLAG_TRANSPARENT, m_pEditor->EnvelopeEval, m_pEditor);
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ void CLayerQuads::BrushSelecting(CUIRect Rect)
|
|||
IGraphics::CLineItem(Rect.x+Rect.w, Rect.y, Rect.x+Rect.w, Rect.y+Rect.h),
|
||||
IGraphics::CLineItem(Rect.x+Rect.w, Rect.y+Rect.h, Rect.x, Rect.y+Rect.h),
|
||||
IGraphics::CLineItem(Rect.x, Rect.y+Rect.h, Rect.x, Rect.y)};
|
||||
Graphics()->TextureSet(-1);
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->LinesBegin();
|
||||
Graphics()->LinesDraw(Array, 4);
|
||||
Graphics()->LinesEnd();
|
||||
|
|
|
@ -19,7 +19,6 @@ CLayerTiles::CLayerTiles(int w, int h)
|
|||
m_Width = w;
|
||||
m_Height = h;
|
||||
m_Image = -1;
|
||||
m_TexID = -1;
|
||||
m_Game = 0;
|
||||
m_Color.r = 255;
|
||||
m_Color.g = 255;
|
||||
|
@ -61,8 +60,8 @@ void CLayerTiles::MakePalette()
|
|||
void CLayerTiles::Render()
|
||||
{
|
||||
if(m_Image >= 0 && m_Image < m_pEditor->m_Map.m_lImages.size())
|
||||
m_TexID = m_pEditor->m_Map.m_lImages[m_Image]->m_TexID;
|
||||
Graphics()->TextureSet(m_TexID);
|
||||
m_Texture = m_pEditor->m_Map.m_lImages[m_Image]->m_Texture;
|
||||
Graphics()->TextureSet(m_Texture);
|
||||
vec4 Color = vec4(m_Color.r/255.0f, m_Color.g/255.0f, m_Color.b/255.0f, m_Color.a/255.0f);
|
||||
m_pEditor->RenderTools()->RenderTilemap(m_pTiles, m_Width, m_Height, 32.0f, Color, LAYERRENDERFLAG_OPAQUE|LAYERRENDERFLAG_TRANSPARENT,
|
||||
m_pEditor->EnvelopeEval, m_pEditor, m_ColorEnv, m_ColorEnvOffset);
|
||||
|
@ -117,7 +116,7 @@ void CLayerTiles::Clamp(RECTi *pRect)
|
|||
|
||||
void CLayerTiles::BrushSelecting(CUIRect Rect)
|
||||
{
|
||||
Graphics()->TextureSet(-1);
|
||||
Graphics()->TextureClear();
|
||||
m_pEditor->Graphics()->QuadsBegin();
|
||||
m_pEditor->Graphics()->SetColor(1.0f, 1.0f, 1.0f, 0.4f);
|
||||
Snap(&Rect);
|
||||
|
@ -141,7 +140,7 @@ int CLayerTiles::BrushGrab(CLayerGroup *pBrush, CUIRect Rect)
|
|||
// create new layers
|
||||
CLayerTiles *pGrabbed = new CLayerTiles(r.w, r.h);
|
||||
pGrabbed->m_pEditor = m_pEditor;
|
||||
pGrabbed->m_TexID = m_TexID;
|
||||
pGrabbed->m_Texture = m_Texture;
|
||||
pGrabbed->m_Image = m_Image;
|
||||
pGrabbed->m_Game = m_Game;
|
||||
pBrush->AddLayer(pGrabbed);
|
||||
|
@ -461,7 +460,7 @@ int CLayerTiles::RenderProperties(CUIRect *pToolBox)
|
|||
{
|
||||
if (NewVal == -1)
|
||||
{
|
||||
m_TexID = -1;
|
||||
m_Texture = IGraphics::CTextureHandle();
|
||||
m_Image = -1;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -578,7 +578,6 @@ int CEditor::PopupPoint(CEditor *pEditor, CUIRect View)
|
|||
{
|
||||
if(pEditor->m_SelectedPoints&(1<<v))
|
||||
{
|
||||
Color = 0;
|
||||
pQuad->m_aColors[v].r = (NewVal>>24)&0xff;
|
||||
pQuad->m_aColors[v].g = (NewVal>>16)&0xff;
|
||||
pQuad->m_aColors[v].b = (NewVal>>8)&0xff;
|
||||
|
@ -833,7 +832,7 @@ int CEditor::PopupSelectImage(CEditor *pEditor, CUIRect View)
|
|||
float Max = (float)(max(pEditor->m_Map.m_lImages[ShowImage]->m_Width, pEditor->m_Map.m_lImages[ShowImage]->m_Height));
|
||||
ImageView.w *= pEditor->m_Map.m_lImages[ShowImage]->m_Width/Max;
|
||||
ImageView.h *= pEditor->m_Map.m_lImages[ShowImage]->m_Height/Max;
|
||||
pEditor->Graphics()->TextureSet(pEditor->m_Map.m_lImages[ShowImage]->m_TexID);
|
||||
pEditor->Graphics()->TextureSet(pEditor->m_Map.m_lImages[ShowImage]->m_Texture);
|
||||
pEditor->Graphics()->BlendNormal();
|
||||
pEditor->Graphics()->WrapClamp();
|
||||
pEditor->Graphics()->QuadsBegin();
|
||||
|
|
|
@ -693,11 +693,14 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
|
|||
void *pRawMsg = m_NetObjHandler.SecureUnpackMsg(MsgID, pUnpacker);
|
||||
CPlayer *pPlayer = m_apPlayers[ClientID];
|
||||
|
||||
if(!pRawMsg && g_Config.m_Debug)
|
||||
if(!pRawMsg)
|
||||
{
|
||||
char aBuf[256];
|
||||
str_format(aBuf, sizeof(aBuf), "dropped weird message '%s' (%d), failed on '%s'", m_NetObjHandler.GetMsgName(MsgID), MsgID, m_NetObjHandler.FailedMsgOn());
|
||||
Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "server", aBuf);
|
||||
if(g_Config.m_Debug)
|
||||
{
|
||||
char aBuf[256];
|
||||
str_format(aBuf, sizeof(aBuf), "dropped weird message '%s' (%d), failed on '%s'", m_NetObjHandler.GetMsgName(MsgID), MsgID, m_NetObjHandler.FailedMsgOn());
|
||||
Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "server", aBuf);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -907,8 +907,8 @@ void IGameController::CycleMap()
|
|||
pNextMap = pMapRotation;
|
||||
|
||||
// cut out the next map
|
||||
char aBuf[512];
|
||||
for(int i = 0; i < 512; i++)
|
||||
char aBuf[512] = {0};
|
||||
for(int i = 0; i < 511; i++)
|
||||
{
|
||||
aBuf[i] = pNextMap[i];
|
||||
if(IsSeparator(pNextMap[i]) || pNextMap[i] == 0)
|
||||
|
|
|
@ -21,7 +21,7 @@ CGameControllerCTF::CGameControllerCTF(CGameContext *pGameServer)
|
|||
}
|
||||
|
||||
// balancing
|
||||
bool CGameControllerCTF::CanBeMovedOnBalance(int ClientID)
|
||||
bool CGameControllerCTF::CanBeMovedOnBalance(int ClientID) const
|
||||
{
|
||||
CCharacter* Character = GameServer()->m_apPlayers[ClientID]->GetCharacter();
|
||||
if(Character)
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
class CGameControllerCTF : public IGameController
|
||||
{
|
||||
// balancing
|
||||
virtual bool CanBeMovedOnBalance(int ClientID);
|
||||
virtual bool CanBeMovedOnBalance(int ClientID) const;
|
||||
|
||||
// game
|
||||
class CFlag *m_apFlags[2];
|
||||
|
|
22
src/versionsrv/mapversions.h
Normal file
22
src/versionsrv/mapversions.h
Normal file
|
@ -0,0 +1,22 @@
|
|||
/* (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. */
|
||||
#ifndef VERSIONSRV_MAPVERSIONS_H
|
||||
#define VERSIONSRV_MAPVERSIONS_H
|
||||
|
||||
static CMapVersion s_aMapVersionList[] = {
|
||||
{"ctf1", {0x06, 0xb5, 0xf1, 0x17}, {0x00, 0x00, 0x12, 0x38}},
|
||||
{"ctf2", {0x27, 0xbc, 0x5e, 0xac}, {0x00, 0x00, 0x64, 0x1a}},
|
||||
{"ctf3", {0xa3, 0x73, 0x9d, 0x41}, {0x00, 0x00, 0x17, 0x0f}},
|
||||
{"ctf4", {0xbe, 0x7c, 0x4d, 0xb9}, {0x00, 0x00, 0x2e, 0xfe}},
|
||||
{"ctf5", {0xd9, 0x21, 0x29, 0xa0}, {0x00, 0x00, 0x2f, 0x4c}},
|
||||
{"ctf6", {0x28, 0xc8, 0x43, 0x51}, {0x00, 0x00, 0x69, 0x2f}},
|
||||
{"ctf7", {0x1d, 0x35, 0x98, 0x72}, {0x00, 0x00, 0x15, 0x87}},
|
||||
{"dm1", {0xf2, 0x15, 0x9e, 0x6e}, {0x00, 0x00, 0x16, 0xad}},
|
||||
{"dm2", {0x71, 0x83, 0x98, 0x78}, {0x00, 0x00, 0x21, 0xdf}},
|
||||
{"dm6", {0x47, 0x4d, 0xa2, 0x35}, {0x00, 0x00, 0x1e, 0x95}},
|
||||
{"dm7", {0x42, 0x6d, 0xa1, 0x67}, {0x00, 0x00, 0x27, 0x2a}},
|
||||
{"dm8", {0x85, 0xf1, 0x1e, 0xd6}, {0x00, 0x00, 0x9e, 0xbd}},
|
||||
{"dm9", {0x42, 0xd4, 0x77, 0x7e}, {0x00, 0x00, 0x20, 0x11}},
|
||||
};
|
||||
static const int s_NumMapVersionItems = sizeof(s_aMapVersionList)/sizeof(CMapVersion);
|
||||
#endif
|
|
@ -11,23 +11,6 @@ struct CMapVersion
|
|||
unsigned char m_aSize[4];
|
||||
};
|
||||
|
||||
static CMapVersion s_aMapVersionList[] = {
|
||||
{"ctf1", {0x06, 0xb5, 0xf1, 0x17}, {0x00, 0x00, 0x12, 0x38}},
|
||||
{"ctf2", {0x27, 0xbc, 0x5e, 0xac}, {0x00, 0x00, 0x64, 0x1a}},
|
||||
{"ctf3", {0xa3, 0x73, 0x9d, 0x41}, {0x00, 0x00, 0x17, 0x0f}},
|
||||
{"ctf4", {0xbe, 0x7c, 0x4d, 0xb9}, {0x00, 0x00, 0x2e, 0xfe}},
|
||||
{"ctf5", {0xd9, 0x21, 0x29, 0xa0}, {0x00, 0x00, 0x2f, 0x4c}},
|
||||
{"ctf6", {0x28, 0xc8, 0x43, 0x51}, {0x00, 0x00, 0x69, 0x2f}},
|
||||
{"ctf7", {0x1d, 0x35, 0x98, 0x72}, {0x00, 0x00, 0x15, 0x87}},
|
||||
{"dm1", {0xf2, 0x15, 0x9e, 0x6e}, {0x00, 0x00, 0x16, 0xad}},
|
||||
{"dm2", {0x71, 0x83, 0x98, 0x78}, {0x00, 0x00, 0x21, 0xdf}},
|
||||
{"dm6", {0x47, 0x4d, 0xa2, 0x35}, {0x00, 0x00, 0x1e, 0x95}},
|
||||
{"dm7", {0x42, 0x6d, 0xa1, 0x67}, {0x00, 0x00, 0x27, 0x2a}},
|
||||
{"dm8", {0x85, 0xf1, 0x1e, 0xd6}, {0x00, 0x00, 0x9e, 0xbd}},
|
||||
{"dm9", {0x42, 0xd4, 0x77, 0x7e}, {0x00, 0x00, 0x20, 0x11}},
|
||||
};
|
||||
static const int s_NumMapVersionItems = sizeof(s_aMapVersionList)/sizeof(CMapVersion);
|
||||
|
||||
static const unsigned char VERSIONSRV_GETVERSION[] = {255, 255, 255, 255, 'v', 'e', 'r', 'g'};
|
||||
static const unsigned char VERSIONSRV_VERSION[] = {255, 255, 255, 255, 'v', 'e', 'r', 's'};
|
||||
|
||||
|
|
Loading…
Reference in a new issue