diff options
| author | Teetime <TeetimeTW@yahoo.de> | 2012-02-17 19:31:43 +0100 |
|---|---|---|
| committer | Teetime <TeetimeTW@yahoo.de> | 2012-02-17 19:31:43 +0100 |
| commit | fc99167e687ba688ce9306bbec7e801450c917be (patch) | |
| tree | b440f2568a98b4b6a8db17925a299142adead7fa /src/tools | |
| parent | 206e9adb9140c3c8963661f534703de33f8abe05 (diff) | |
| parent | 44a47d4253a829abcf50dac5586fd9a351f0c66b (diff) | |
| download | zcatch-fc99167e687ba688ce9306bbec7e801450c917be.tar.gz zcatch-fc99167e687ba688ce9306bbec7e801450c917be.zip | |
Merge branch 'master' into zCatch-Exp
Conflicts: src/engine/server.h src/engine/server/server.cpp src/engine/server/server.h src/engine/shared/network.h src/engine/shared/network_server.cpp src/game/server/player.h
Diffstat (limited to 'src/tools')
| -rw-r--r-- | src/tools/crapnet.cpp | 4 | ||||
| -rw-r--r-- | src/tools/dilate.cpp | 2 | ||||
| -rw-r--r-- | src/tools/fake_server.cpp | 2 | ||||
| -rw-r--r-- | src/tools/map_resave.cpp | 4 | ||||
| -rw-r--r-- | src/tools/map_version.cpp | 2 | ||||
| -rw-r--r-- | src/tools/tileset_borderadd.cpp | 86 | ||||
| -rw-r--r-- | src/tools/tileset_borderrem.cpp | 86 | ||||
| -rw-r--r-- | src/tools/tileset_borderset.cpp | 78 |
8 files changed, 257 insertions, 7 deletions
diff --git a/src/tools/crapnet.cpp b/src/tools/crapnet.cpp index 98b6c0a7..fbd20445 100644 --- a/src/tools/crapnet.cpp +++ b/src/tools/crapnet.cpp @@ -129,7 +129,7 @@ void Run(int Port, NETADDR Dest) if(m_ConfigLog) { char aAddrStr[NETADDR_MAXSTRSIZE]; - net_addr_str(&From, aAddrStr, sizeof(aAddrStr)); + net_addr_str(&From, aAddrStr, sizeof(aAddrStr), true); dbg_msg("crapnet", "<< %08d %s (%d)", p->m_ID, aAddrStr, p->m_DataSize); } } @@ -193,7 +193,7 @@ void Run(int Port, NETADDR Dest) if(m_ConfigLog) { char aAddrStr[NETADDR_MAXSTRSIZE]; - net_addr_str(&p->m_SendTo, aAddrStr, sizeof(aAddrStr)); + net_addr_str(&p->m_SendTo, aAddrStr, sizeof(aAddrStr), true); dbg_msg("crapnet", ">> %08d %s (%d) %s", p->m_ID, aAddrStr, p->m_DataSize, aFlags); } diff --git a/src/tools/dilate.cpp b/src/tools/dilate.cpp index eb770a90..55094a5b 100644 --- a/src/tools/dilate.cpp +++ b/src/tools/dilate.cpp @@ -96,7 +96,7 @@ int main(int argc, const char **argv) dbg_msg("Usage", "%s FILE1 [ FILE2... ]", argv[0]); return -1; } - + for(int i = 1; i < argc; i++) DilateFile(argv[i]); return 0; diff --git a/src/tools/fake_server.cpp b/src/tools/fake_server.cpp index 68c47659..9e76b3e7 100644 --- a/src/tools/fake_server.cpp +++ b/src/tools/fake_server.cpp @@ -113,7 +113,7 @@ static int Run() int64 NextHeartBeat = 0; NETADDR BindAddr = {NETTYPE_IPV4, {0},0}; - if(!pNet->Open(BindAddr, 0, 0, 0)) + if(!pNet->Open(BindAddr, 0, 0, 0, 0)) return 0; while(1) diff --git a/src/tools/map_resave.cpp b/src/tools/map_resave.cpp index a536f021..0a624b0f 100644 --- a/src/tools/map_resave.cpp +++ b/src/tools/map_resave.cpp @@ -6,7 +6,7 @@ int main(int argc, const char **argv) { - IStorage *pStorage = CreateStorage("Teeworlds", argc, argv); + IStorage *pStorage = CreateStorage("Teeworlds", IStorage::STORAGETYPE_BASIC, argc, argv); int Index, ID = 0, Type = 0, Size; void *pPtr; char aFileName[1024]; @@ -16,7 +16,7 @@ int main(int argc, const char **argv) if(!pStorage || argc != 3) return -1; - str_format(aFileName, sizeof(aFileName), "maps/%s", argv[2]); + str_format(aFileName, sizeof(aFileName), "%s", argv[2]); if(!DataFile.Open(pStorage, argv[1], IStorage::TYPE_ALL)) return -1; diff --git a/src/tools/map_version.cpp b/src/tools/map_version.cpp index 4acc51e0..8d8c59e3 100644 --- a/src/tools/map_version.cpp +++ b/src/tools/map_version.cpp @@ -44,7 +44,7 @@ int MaplistCallback(const char *pName, int IsDir, int DirType, void *pUser) int main(int argc, const char **argv) // ignore_convention { IKernel *pKernel = IKernel::Create(); - s_pStorage = CreateStorage("Teeworlds", argc, argv); + s_pStorage = CreateStorage("Teeworlds", IStorage::STORAGETYPE_BASIC, argc, argv); s_pEngineMap = CreateEngineMap(); bool RegisterFail = !pKernel->RegisterInterface(s_pStorage); diff --git a/src/tools/tileset_borderadd.cpp b/src/tools/tileset_borderadd.cpp new file mode 100644 index 00000000..25e2fa5e --- /dev/null +++ b/src/tools/tileset_borderadd.cpp @@ -0,0 +1,86 @@ +/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */ +/* If you are missing that file, acquire a complete release at teeworlds.com. */ +#include <base/math.h> +#include <base/system.h> +#include <engine/external/pnglite/pnglite.h> + +typedef struct +{ + unsigned char r, g, b, a; +} CPixel; + +static void TilesetBorderadd(int w, int h, CPixel *pSrc, CPixel *pDest) +{ + int TileW = w/16; + int TileH = h/16; + + for(int tx = 0; tx < 16; tx++) + { + for(int ty = 0; ty < 16; ty++) + { + for(int x = 0; x < TileW + 4; x++) + { + for(int y = 0; y < TileH + 4; y++) + { + int SourceX = tx * TileW + clamp(x - 2, 0, TileW - 1); + int SourceY = ty * TileH + clamp(y - 2, 0, TileH - 1); + int DestX = tx * (TileW + 4) + x; + int DestY = ty * (TileH + 4) + y; + + int SourceI = SourceY * w + SourceX; + int DestI = DestY * (w + 16 * 4) + DestX; + + pDest[DestI] = pSrc[SourceI]; + + } + } + } + } +} + + +int FixFile(const char *pFileName) +{ + png_t Png; + CPixel *pBuffer[2] = {0,0}; + + png_init(0, 0); + png_open_file(&Png, pFileName); + + if(Png.color_type != PNG_TRUECOLOR_ALPHA) + { + dbg_msg("tileset_borderadd", "%s: not an RGBA image", pFileName); + return 1; + } + + int w = Png.width; + int h = Png.height; + + pBuffer[0] = (CPixel*)mem_alloc(w*h*sizeof(CPixel), 1); + pBuffer[1] = (CPixel*)mem_alloc((w+16*4)*(h+16*4)*sizeof(CPixel), 1); + png_get_data(&Png, (unsigned char *)pBuffer[0]); + png_close_file(&Png); + + TilesetBorderadd(w, h, pBuffer[0], pBuffer[1]); + + // save here + png_open_file_write(&Png, pFileName); + png_set_data(&Png, w + 16 * 4, h + 16 * 4, 8, PNG_TRUECOLOR_ALPHA, (unsigned char *)pBuffer[1]); + png_close_file(&Png); + + return 0; +} + +int main(int argc, const char **argv) +{ + dbg_logger_stdout(); + if(argc == 1) + { + dbg_msg("Usage", "%s FILE1 [ FILE2... ]", argv[0]); + return -1; + } + + for(int i = 1; i < argc; i++) + FixFile(argv[i]); + return 0; +} diff --git a/src/tools/tileset_borderrem.cpp b/src/tools/tileset_borderrem.cpp new file mode 100644 index 00000000..d604ecbd --- /dev/null +++ b/src/tools/tileset_borderrem.cpp @@ -0,0 +1,86 @@ +/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */ +/* If you are missing that file, acquire a complete release at teeworlds.com. */ +#include <base/math.h> +#include <base/system.h> +#include <engine/external/pnglite/pnglite.h> + +typedef struct +{ + unsigned char r, g, b, a; +} CPixel; + +static void TilesetBorderrem(int w, int h, CPixel *pSrc, CPixel *pDest) +{ + int TileW = w/16; + int TileH = h/16; + + for(int tx = 0; tx < 16; tx++) + { + for(int ty = 0; ty < 16; ty++) + { + for(int x = 0; x < TileW - 4; x++) + { + for(int y = 0; y < TileH - 4; y++) + { + int SourceX = tx * TileW + x + 2; + int SourceY = ty * TileH + y + 2; + int DestX = tx * (TileW - 4) + x; + int DestY = ty * (TileH - 4) + y; + + int SourceI = SourceY * w + SourceX; + int DestI = DestY * (w - 16 * 4) + DestX; + + pDest[DestI] = pSrc[SourceI]; + + } + } + } + } +} + + +int FixFile(const char *pFileName) +{ + png_t Png; + CPixel *pBuffer[2] = {0,0}; + + png_init(0, 0); + png_open_file(&Png, pFileName); + + if(Png.color_type != PNG_TRUECOLOR_ALPHA) + { + dbg_msg("tileset_borderrem", "%s: not an RGBA image", pFileName); + return 1; + } + + int w = Png.width; + int h = Png.height; + + pBuffer[0] = (CPixel*)mem_alloc(w*h*sizeof(CPixel), 1); + pBuffer[1] = (CPixel*)mem_alloc((w-16*4)*(h-16*4)*sizeof(CPixel), 1); + png_get_data(&Png, (unsigned char *)pBuffer[0]); + png_close_file(&Png); + + TilesetBorderrem(w, h, pBuffer[0], pBuffer[1]); + + // save here + png_open_file_write(&Png, pFileName); + png_set_data(&Png, w - 16 * 4, h - 16 * 4, 8, PNG_TRUECOLOR_ALPHA, (unsigned char *)pBuffer[1]); + png_close_file(&Png); + + return 0; +} + +int main(int argc, const char **argv) +{ + dbg_logger_stdout(); + if(argc == 1) + { + dbg_msg("Usage", "%s FILE1 [ FILE2... ]", argv[0]); + return -1; + } + + for(int i = 1; i < argc; i++) + FixFile(argv[i]); + return 0; +} diff --git a/src/tools/tileset_borderset.cpp b/src/tools/tileset_borderset.cpp new file mode 100644 index 00000000..8b3e2996 --- /dev/null +++ b/src/tools/tileset_borderset.cpp @@ -0,0 +1,78 @@ +/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */ +/* If you are missing that file, acquire a complete release at teeworlds.com. */ +#include <base/math.h> +#include <base/system.h> +#include <engine/external/pnglite/pnglite.h> + +typedef struct +{ + unsigned char r, g, b, a; +} CPixel; + +static void TilesetBorderset(int w, int h, CPixel *pSrc, CPixel *pDest) +{ + int TileW = w/16; + int TileH = h/16; + + for(int tx = 0; tx < 16; tx++) + { + for(int ty = 0; ty < 16; ty++) + { + for(int x = 0; x < TileW; x++) + { + for(int y = 0; y < TileH; y++) + { + #define TILE_INDEX(tx_, ty_, x_, y_) (((ty_) * TileH + (y_)) * w + (tx_) * TileW + (x_)) + pDest[TILE_INDEX(tx, ty, x, y)] = pSrc[TILE_INDEX(tx, ty, clamp(x, 2, TileW - 3), clamp(y, 2, TileH - 3))]; + } + } + } + } +} + + +int FixFile(const char *pFileName) +{ + png_t Png; + CPixel *pBuffer[2] = {0,0}; + + png_init(0, 0); + png_open_file(&Png, pFileName); + + if(Png.color_type != PNG_TRUECOLOR_ALPHA) + { + dbg_msg("tileset_borderset", "%s: not an RGBA image", pFileName); + return 1; + } + + int w = Png.width; + int h = Png.height; + + pBuffer[0] = (CPixel*)mem_alloc(w*h*sizeof(CPixel), 1); + pBuffer[1] = (CPixel*)mem_alloc(w*h*sizeof(CPixel), 1); + png_get_data(&Png, (unsigned char *)pBuffer[0]); + png_close_file(&Png); + + TilesetBorderset(w, h, pBuffer[0], pBuffer[1]); + + // save here + png_open_file_write(&Png, pFileName); + png_set_data(&Png, w, h, 8, PNG_TRUECOLOR_ALPHA, (unsigned char *)pBuffer[1]); + png_close_file(&Png); + + return 0; +} + +int main(int argc, const char **argv) +{ + dbg_logger_stdout(); + if(argc == 1) + { + dbg_msg("Usage", "%s FILE1 [ FILE2... ]", argv[0]); + return -1; + } + + for(int i = 1; i < argc; i++) + FixFile(argv[i]); + return 0; +} |