diff options
| author | oy <Tom_Adams@web.de> | 2011-04-13 20:37:12 +0200 |
|---|---|---|
| committer | oy <Tom_Adams@web.de> | 2011-04-13 20:37:12 +0200 |
| commit | 06115dd49dca2f8eb5f14606437e8fd20037cc4d (patch) | |
| tree | 5ec4bca6158319b3f5285d7689c5f94ae8da8c93 /src/tools | |
| parent | 63e059b8fff6498e42b765a1dca000e53005ea77 (diff) | |
| download | zcatch-06115dd49dca2f8eb5f14606437e8fd20037cc4d.tar.gz zcatch-06115dd49dca2f8eb5f14606437e8fd20037cc4d.zip | |
added "Whitespace and line Endings cleanup" by GreYFoX
Diffstat (limited to 'src/tools')
| -rw-r--r-- | src/tools/crapnet.cpp | 40 | ||||
| -rw-r--r-- | src/tools/dilate.cpp | 20 | ||||
| -rw-r--r-- | src/tools/fake_server.cpp | 26 | ||||
| -rw-r--r-- | src/tools/map_resave.cpp | 2 | ||||
| -rw-r--r-- | src/tools/map_version.cpp | 6 | ||||
| -rw-r--r-- | src/tools/packetgen.cpp | 4 | ||||
| -rw-r--r-- | src/tools/tileset_borderfix.cpp | 22 |
7 files changed, 60 insertions, 60 deletions
diff --git a/src/tools/crapnet.cpp b/src/tools/crapnet.cpp index 35ca09bc..98b6c0a7 100644 --- a/src/tools/crapnet.cpp +++ b/src/tools/crapnet.cpp @@ -8,7 +8,7 @@ struct CPacket { CPacket *m_pPrev; CPacket *m_pNext; - + NETADDR m_SendTo; int64 m_Timestamp; int m_ID; @@ -46,21 +46,21 @@ void Run(int Port, NETADDR Dest) { NETADDR Src = {NETTYPE_IPV4, {0,0,0,0}, Port}; NETSOCKET Socket = net_udp_create(Src); - + char aBuffer[1024*2]; int ID = 0; int Delaycounter = 0; - + while(1) { static int Lastcfg = 0; int n = ((time_get()/time_freq())/m_ConfigInterval) % m_ConfigNumpingconfs; CPingConfig Ping = m_aConfigPings[n]; - + if(n != Lastcfg) dbg_msg("crapnet", "cfg = %d", n); Lastcfg = n; - + // handle incomming packets while(1) { @@ -70,7 +70,7 @@ void Run(int Port, NETADDR Dest) int Bytes = net_udp_recv(Socket, &From, aBuffer, 1024*2); if(Bytes <= 0) break; - + if((rand()%100) < Ping.m_Loss) // drop the packet { if(m_ConfigLog) @@ -78,7 +78,7 @@ void Run(int Port, NETADDR Dest) continue; } - // create new packet + // create new packet CPacket *p = (CPacket *)mem_alloc(sizeof(CPacket)+Bytes, 1); if(net_addr_comp(&From, &Dest) == 0) @@ -106,7 +106,7 @@ void Run(int Port, NETADDR Dest) p->m_DataSize = Bytes; p->m_ID = ID++; mem_copy(p->m_aData, aBuffer, Bytes); - + if(ID > 20 && Bytes > 6 && DataTrash) { p->m_aData[6+(rand()%(Bytes-6))] = rand()&255; // modify a byte @@ -117,7 +117,7 @@ void Run(int Port, NETADDR Dest) p->m_DataSize = 6; } } - + if(Delaycounter <= 0) { if(Ping.m_Delay) @@ -125,7 +125,7 @@ void Run(int Port, NETADDR Dest) Delaycounter = Ping.m_DelayFreq; } Delaycounter--; - + if(m_ConfigLog) { char aAddrStr[NETADDR_MAXSTRSIZE]; @@ -133,7 +133,7 @@ void Run(int Port, NETADDR Dest) dbg_msg("crapnet", "<< %08d %s (%d)", p->m_ID, aAddrStr, p->m_DataSize); } } - + // /*while(1) {*/ @@ -145,7 +145,7 @@ void Run(int Port, NETADDR Dest) if(!p) break; pNext = p->m_pNext; - + if((time_get()-p->m_Timestamp) > m_CurrentLatency) { char aFlags[] = " "; @@ -155,35 +155,35 @@ void Run(int Port, NETADDR Dest) aFlags[0] = 'R'; p = m_pFirst->m_pNext; } - + if(p->m_pNext) p->m_pNext->m_pPrev = p->m_pPrev; else m_pLast = p->m_pPrev; - + if(p->m_pPrev) p->m_pPrev->m_pNext = p->m_pNext; else m_pFirst = p->m_pNext; - + /*CPacket *cur = first; while(cur) { dbg_assert(cur != p, "p still in list"); cur = cur->next; }*/ - + // send and remove packet //if((rand()%20) != 0) // heavy packetloss net_udp_send(Socket, &p->m_SendTo, p->m_aData, p->m_DataSize); - + // update lag double Flux = rand()/(double)RAND_MAX; int MsSpike = Ping.m_Spike; int MsFlux = Ping.m_Flux; int MsPing = Ping.m_Base; m_CurrentLatency = ((time_freq()*MsPing)/1000) + (int64)(((time_freq()*MsFlux)/1000)*Flux); // 50ms - + if(MsSpike && (p->m_ID%100) == 0) { m_CurrentLatency += (time_freq()*MsSpike)/1000; @@ -196,12 +196,12 @@ void Run(int Port, NETADDR Dest) net_addr_str(&p->m_SendTo, aAddrStr, sizeof(aAddrStr)); dbg_msg("crapnet", ">> %08d %s (%d) %s", p->m_ID, aAddrStr, p->m_DataSize, aFlags); } - + mem_free(p); } } - + thread_sleep(1); } } diff --git a/src/tools/dilate.cpp b/src/tools/dilate.cpp index b1b60ac3..ef862270 100644 --- a/src/tools/dilate.cpp +++ b/src/tools/dilate.cpp @@ -14,7 +14,7 @@ static void Dilate(int w, int h, CPixel *pSrc, CPixel *pDest) int ix, iy; const int xo[] = {0, -1, 1, 0}; const int yo[] = {-1, 0, 0, 1}; - + int m = 0; for(int y = 0; y < h; y++) { @@ -23,7 +23,7 @@ static void Dilate(int w, int h, CPixel *pSrc, CPixel *pDest) pDest[m] = pSrc[m]; if(pSrc[m].a) continue; - + for(int c = 0; c < 4; c++) { ix = clamp(x + xo[c], 0, w-1); @@ -52,38 +52,38 @@ int main(int argc, char **argv) { png_t Png; CPixel *pBuffer[3] = {0,0,0}; - + png_init(0, 0); png_open_file(&Png, argv[1]); - + if(Png.color_type != PNG_TRUECOLOR_ALPHA) { dbg_msg("dilate", "not an RGBA image"); return -1; } - + pBuffer[0] = (CPixel*)mem_alloc(Png.width*Png.height*sizeof(CPixel), 1); pBuffer[1] = (CPixel*)mem_alloc(Png.width*Png.height*sizeof(CPixel), 1); pBuffer[2] = (CPixel*)mem_alloc(Png.width*Png.height*sizeof(CPixel), 1); png_get_data(&Png, (unsigned char *)pBuffer[0]); png_close_file(&Png); - + int w = Png.width; int h = Png.height; - + Dilate(w, h, pBuffer[0], pBuffer[1]); for(int i = 0; i < 5; i++) { Dilate(w, h, pBuffer[1], pBuffer[2]); Dilate(w, h, pBuffer[2], pBuffer[1]); } - + CopyAlpha(w, h, pBuffer[0], pBuffer[1]); - + // save here png_open_file_write(&Png, argv[1]); png_set_data(&Png, w, h, 8, PNG_TRUECOLOR_ALPHA, (unsigned char *)pBuffer[1]); png_close_file(&Png); - + return 0; } diff --git a/src/tools/fake_server.cpp b/src/tools/fake_server.cpp index ac7a8ed9..68c47659 100644 --- a/src/tools/fake_server.cpp +++ b/src/tools/fake_server.cpp @@ -31,18 +31,18 @@ static void SendHeartBeats() { static unsigned char aData[sizeof(SERVERBROWSE_HEARTBEAT) + 2]; CNetChunk Packet; - + mem_copy(aData, SERVERBROWSE_HEARTBEAT, sizeof(SERVERBROWSE_HEARTBEAT)); - + Packet.m_ClientID = -1; Packet.m_Flags = NETSENDFLAG_CONNLESS; Packet.m_DataSize = sizeof(SERVERBROWSE_HEARTBEAT) + 2; Packet.m_pData = &aData; - /* supply the set port that the master can use if it has problems */ + /* supply the set port that the master can use if it has problems */ aData[sizeof(SERVERBROWSE_HEARTBEAT)] = 0; aData[sizeof(SERVERBROWSE_HEARTBEAT)+1] = 0; - + for(int i = 0; i < NumMasters; i++) { Packet.m_Address = aMasterServers[i]; @@ -78,7 +78,7 @@ static void BuildInfoMsg() WriteInt(Progression); WriteInt(NumPlayers); WriteInt(MaxPlayers); - + for(int i = 0; i < NumPlayers; i++) { WriteStr(PlayerNames[i]); @@ -112,10 +112,10 @@ static int Run() { int64 NextHeartBeat = 0; NETADDR BindAddr = {NETTYPE_IPV4, {0},0}; - + if(!pNet->Open(BindAddr, 0, 0, 0)) return 0; - + while(1) { CNetChunk p; @@ -136,14 +136,14 @@ static int Run() } } } - + /* send heartbeats if needed */ if(NextHeartBeat < time_get()) { NextHeartBeat = time_get()+time_freq()*(15+(rand()%15)); SendHeartBeats(); } - + thread_sleep(100); } } @@ -151,7 +151,7 @@ static int Run() int main(int argc, char **argv) { pNet = new CNetServer; - + while(argc) { // ? @@ -200,13 +200,13 @@ int main(int argc, char **argv) argc--; argv++; pServerName = *argv; } - + argc--; argv++; } - + BuildInfoMsg(); int RunReturn = Run(); - + delete pNet; return RunReturn; } diff --git a/src/tools/map_resave.cpp b/src/tools/map_resave.cpp index d97f0323..a536f021 100644 --- a/src/tools/map_resave.cpp +++ b/src/tools/map_resave.cpp @@ -25,7 +25,7 @@ int main(int argc, const char **argv) // add all items for(Index = 0; Index < DataFile.NumItems(); Index++) - { + { pPtr = DataFile.GetItem(Index, &Type, &ID); Size = DataFile.GetItemSize(Index); df.AddItem(Type, ID, Size, pPtr); diff --git a/src/tools/map_version.cpp b/src/tools/map_version.cpp index d995f478..4acc51e0 100644 --- a/src/tools/map_version.cpp +++ b/src/tools/map_version.cpp @@ -29,7 +29,7 @@ int MaplistCallback(const char *pName, int IsDir, int DirType, void *pUser) IOHANDLE MapFile = s_pStorage->OpenFile(aBuf, IOFLAG_READ, DirType); unsigned MapSize = io_length(MapFile); io_close(MapFile); - + char aMapName[8]; str_copy(aMapName, pName, min((int)sizeof(aMapName),l-3)); @@ -52,7 +52,7 @@ int main(int argc, const char **argv) // ignore_convention if(RegisterFail) return -1; - + s_File = s_pStorage->OpenFile("map_version.txt", IOFLAG_WRITE, 1); if(s_File) { @@ -61,6 +61,6 @@ int main(int argc, const char **argv) // ignore_convention io_write(s_File, "};\n", str_length("};\n")); io_close(s_File); } - + return 0; } diff --git a/src/tools/packetgen.cpp b/src/tools/packetgen.cpp index 7e9a8a19..9b52aadc 100644 --- a/src/tools/packetgen.cpp +++ b/src/tools/packetgen.cpp @@ -7,13 +7,13 @@ enum { NUM_SOCKETS = 64 }; void Run(NETADDR Dest) { NETSOCKET aSockets[NUM_SOCKETS]; - + for(int i = 0; i < NUM_SOCKETS; i++) { NETADDR BindAddr = {NETTYPE_IPV4, {0}, 0}; aSockets[i] = net_udp_create(BindAddr); } - + while(1) { unsigned char aData[1024]; diff --git a/src/tools/tileset_borderfix.cpp b/src/tools/tileset_borderfix.cpp index d28e3074..b5eef77a 100644 --- a/src/tools/tileset_borderfix.cpp +++ b/src/tools/tileset_borderfix.cpp @@ -20,9 +20,9 @@ static void TilesetBorderfix(int w, int h, CPixel *pSrc, CPixel *pDest) { int TileW = w/16; int TileH = h/16; - + mem_zero(pDest, sizeof(CPixel)*w*h); - + for(int ty = 0; ty < 16; ty++) { for(int tx = 0; tx < 16; tx++) @@ -35,12 +35,12 @@ static void TilesetBorderfix(int w, int h, CPixel *pSrc, CPixel *pDest) float v = 0.5f/TileH + y/(float)(TileH-2); int k = (ty*TileH+1+y)*w + tx*TileW+x+1; pDest[k] = Sample(tx*TileW, ty*TileH, TileW, TileH, pSrc, w, u, v); - + if(x == 0) pDest[k-1] = pDest[k]; if(x == TileW-2-1) pDest[k+1] = pDest[k]; if(y == 0) pDest[k-w] = pDest[k]; if(y == TileH-2-1) pDest[k+w] = pDest[k]; - + if(x == 0 && y == 0) pDest[k-w-1] = pDest[k]; if(x == TileW-2-1 && y == 0) pDest[k-w+1] = pDest[k]; if(x == 0 && y == TileH-2-1) pDest[k+w-1] = pDest[k]; @@ -56,30 +56,30 @@ int main(int argc, char **argv) { png_t Png; CPixel *pBuffer[2] = {0,0}; - + png_init(0, 0); png_open_file(&Png, argv[1]); - + if(Png.color_type != PNG_TRUECOLOR_ALPHA) { dbg_msg("dilate", "not an RGBA image"); 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); - + TilesetBorderfix(w, h, pBuffer[0], pBuffer[1]); - + // save here png_open_file_write(&Png, argv[1]); png_set_data(&Png, w, h, 8, PNG_TRUECOLOR_ALPHA, (unsigned char *)pBuffer[1]); png_close_file(&Png); - + return 0; } |