[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[netPanzer-CVS] netpanzer/src ChangeLog Makefile Lib/2D/Surface...
From: |
Matthias Braun |
Subject: |
[netPanzer-CVS] netpanzer/src ChangeLog Makefile Lib/2D/Surface... |
Date: |
Fri, 12 Sep 2003 17:37:10 -0400 |
CVSROOT: /cvsroot/netpanzer
Module name: netpanzer
Branch:
Changes by: Matthias Braun <address@hidden> 03/09/12 17:37:10
Modified files:
src : ChangeLog Makefile
src/Lib/2D : Surface.cpp Surface.hpp
src/NetPanzer/Interfaces: ConsoleInterface.cpp
ConsoleInterface.hpp GameManager.cpp
src/NetPanzer/Views/Game: GameTemplateView.cpp
Log message:
-removed lots of unused code from Surface class
-removed the screenshot function (this allowed to remove the BMP saver
too).
because there are external screenshot tools around.
Patches:
Index: netpanzer/src/ChangeLog
diff -u netpanzer/src/ChangeLog:1.18 netpanzer/src/ChangeLog:1.19
--- netpanzer/src/ChangeLog:1.18 Fri Sep 12 10:12:45 2003
+++ netpanzer/src/ChangeLog Fri Sep 12 17:37:09 2003
@@ -1,5 +1,8 @@
12-Sep-2003 by Matze Braun
-use the physfs for the colortable cache now
+-removed lots of unused code from Surface class
+-removed the screenshot function (this allowed to remove the BMP saver too).
+ because there are external screenshot tools around.
11-Sep-2003 by Matze Braun
-removed more win32 specific code
Index: netpanzer/src/Lib/2D/Surface.cpp
diff -u netpanzer/src/Lib/2D/Surface.cpp:1.17
netpanzer/src/Lib/2D/Surface.cpp:1.18
--- netpanzer/src/Lib/2D/Surface.cpp:1.17 Thu Sep 11 13:35:46 2003
+++ netpanzer/src/Lib/2D/Surface.cpp Fri Sep 12 17:37:10 2003
@@ -4168,33 +4168,17 @@
}
}
-// Blit a string of text with a horizontal gradient.
//---------------------------------------------------------------------------
-void Surface::bltStringHGradient(const iXY &pos, const char *string,
ColorTable &colorTable) const
+void Surface::bltChar8x8VGradient(const iXY &pos, const char &character,
+ ColorTable
&colorTable) const
{
assert(screenLocked);
-
- int xSize = strlen(string) * CHAR_XPIX;
-
- Surface tempSurface(xSize, CHAR_YPIX, xSize, 1);
-
- tempSurface.bltString(iXY(0, 0), string, Color::white);
-
- tempSurface.bltTransHGradient(*this, pos, colorTable);
-}
-
-//---------------------------------------------------------------------------
-void Surface::bltChar8x8VGradient(const iXY &pos, const char &character,
ColorTable &colorTable) const
-{
- assert(screenLocked);
-
#ifdef _DEBUG
if (character > ascii8x8.getFrameCount())
{
assert(false);
}
#endif
-
ascii8x8.setFrame(character);
ascii8x8.bltTransVGradient(*this, pos, colorTable);
}
@@ -4299,173 +4283,6 @@
}
}
-//---------------------------------------------------------------------------
-void Surface::bltTransHGradient(const Surface &dest, const iXY &pos,
ColorTable &colorTable) const
-{
- assert(screenLocked);
-
-}
-
-//---------------------------------------------------------------------------
-int Surface::savePCX( Palette &pal )
-{
- char strBuf[256];
- int num = 0;
-
- // Incrementally create screen shots.
- for(;;)
- {
- sprintf(strBuf, "shot%04d.pcx", num);
-
- if (UtilInterface::getFileSize(strBuf) <= 0)
- {
- if (!savePCX(strBuf, pal))
- {
- return false;
- }
- return true;
- } else num++;
- }
- return true;
-
- }
-
-//---------------------------------------------------------------------------
-inline long pcx_putc( unsigned long c, unsigned long n, FILE *fp )
-{
- if ( (n > 1) || ( (c & 0xc0) == 0xc0 ) )
- { while ( n > 0x3f )
- if ( pcx_putc( c, 0x3f, fp ) )
- return ( 1 );
- else n -= 0x3f;
-
- if ( !n )
- return (0);
-
- if ( fputc( 0xc0 | n, fp ) == EOF )
- return ( 1 );
- };
-
- if ( fputc( c, fp ) == EOF )
- return ( 1 );
-
- return (0);
-}
-
-//---------------------------------------------------------------------------
-inline long pcx_xputc( long c, FILE *fp )
-{
- long i;
- static long csave = -1, n = -1;
-
- if ( c == -1 )
- { if ( csave != -1 )
- if ( pcx_putc( csave, n, fp ) )
- return ( 1 );
- csave = n = -1;
- return (0);
- };
-
- if ( c == csave )
- { n++;
- return (0);
- };
-
- if ( csave != -1 )
- {
- // XXX is this = intended here? (I added the braces to avoid
the
- // warning now...)
- if ( (i = pcx_putc( csave, n, fp )) )
- return i;
- csave = n = -1;
- };
-
- csave = c;
- n = 1;
- return (0);
-}
-
-//---------------------------------------------------------------------------
-void Surface::savePCX(FILE *fp, Palette &pal )
-{
- PcxHeader header;
-
- header.manufacturer = 10;
- header.version = 5;
- header.encoding = 1;
- header.bits_per_pixel = 8;
- header.x = 0;
- header.y = 0; //upper left of image
- header.width = getPix().x - 1;
- header.height = getPix().y - 1; //size of the image
- header.horz_res = 150; //horizontal resolution
- header.vert_res = 150; //vertical resolution
- header.reserved = 0;
- header.num_color_planes = 1;
- header.bytes_per_line = getPix().x;
- header.palette_type = 1;
-
- memset( header.padding, 0, 58 );
- fwrite( &header, 1, sizeof( PcxHeader ), fp );
-
- //int h_res = header.bytes_per_line;
- //int v_res = (header.height - header.x) + 2;
-
- int h_res = getPix().x;
- int v_res = getPix().y;
-
- PIX *buff_ptr = mem;
-
- for ( int y = 0; y < v_res; y++ )
- {
- for ( int x = 0; x < h_res; x++ )
- {
- if ( pcx_xputc( *buff_ptr++, fp ) )
- return;
- }
- pcx_xputc( -1, fp );
- }
-
- pcx_xputc( -1, fp );
-
- unsigned char c = 12; // indicates VGA pallete
-
- fwrite ( &c, 1, 1, fp );
-
- //now load the palette into the vga registers
- for(int index = 0; index < 256; index++)
- {
- RGBColor color;
-
- color = pal[ index ];
-
- c = color.red;
- fwrite ( &c, 1, 1, fp );
-
- c = color.green;
- fwrite ( &c, 1, 1, fp );
-
- c = color.blue;
- fwrite ( &c, 1, 1, fp );
-
- }//end for index that loads the palette
-
-}
-
-//---------------------------------------------------------------------------
-int Surface::savePCX( const char *filename, Palette &pal )
-{
- FILE *fp = fopen(filename, "wb");
-
- if (fp == 0) return 0;
-
- savePCX(fp, pal);
-
- fclose(fp);
-
- return 1;
-}
-
// convertTransColor
//---------------------------------------------------------------------------
void Surface::convertTransColor(const PIX &color)
@@ -4487,84 +4304,6 @@
}
} // end Surface::convertTransColor
-// saveSUR
-//---------------------------------------------------------------------------
-int Surface::saveSUR(const char *filename)
-{
- FILE *fp = fopen(filename, "wb");
- if (fp == 0) { return 0; }
-
- saveSUR(fp);
-
- fclose(fp);
-
- return 1;
-
-} // end Surface::saveSUR
-
-// saveSUR
-//---------------------------------------------------------------------------
-void Surface::saveSUR(FILE *fp)
-{
- SurfaceHeader surfaceHeader;
-
- surfaceHeader.pixX = pix.x;
- surfaceHeader.pixY = pix.y;
- surfaceHeader.offsetX = offset.x;
- surfaceHeader.offsetY = offset.y;
- surfaceHeader.frameCount = frameCount;
- surfaceHeader.fps = fps;
-
- fwrite(&surfaceHeader, sizeof(SurfaceHeader), 1, fp);
-
- // Write the actual data...
- for (int i = 0; i < frameCount; i++)
- {
- setFrame(i);
-
- fwrite(mem, sizeof(PIX), pix.x * pix.y, fp);
- }
-
-} // end Surface::saveSUR
-
-// loadSUR
-//---------------------------------------------------------------------------
-int Surface::loadSUR(const char *filename)
-{
- FILE *fp = fopen(filename, "rb");
- if (fp == 0) { return 0; }
-
- loadSUR(fp);
-
- fclose(fp);
-
- return 1;
-
-} // end Surface::loadSUR
-
-// loadSUR
-//---------------------------------------------------------------------------
-void Surface::loadSUR(FILE *fp)
-{
- SurfaceHeader surfaceHeader;
-
- fread(&surfaceHeader, sizeof(SurfaceHeader), 1, fp);
-
- create(surfaceHeader.pixX, surfaceHeader.pixY, surfaceHeader.pixX,
surfaceHeader.frameCount);
-
- setOffset(iXY(surfaceHeader.offsetX, surfaceHeader.offsetY));
- setFPS((int) surfaceHeader.fps);
-
- // Write the actual data...
- for (int i = 0; i < frameCount; i++)
- {
- setFrame(i);
-
- fread(mem, sizeof(PIX), pix.x * pix.y, fp);
- }
-
-} // end Surface::loadSUR
-
// lock
//---------------------------------------------------------------------------
void Surface::lock(PIX *memBuf)
@@ -4572,8 +4311,6 @@
screenLocked = true;
frame0 = mem = memBuf;
doesExist = true;
-
-
} // end Surface::lock
// unlock
@@ -4583,8 +4320,6 @@
screenLocked = true;
frame0 = mem = 0;
doesExist = false;
-
-
} // end Surface::unlock
// create
@@ -4717,125 +4452,7 @@
fclose(fp);
flipVertical();
- }
-
-
-
-void Surface::saveBMP(FILE *fp, Palette &pal )
- {
- BitmapFileHeader file_header;
- BitmapInfoHeader info_header;
- RGBQuad palette[256];
-
- file_header.bfType = 0x4D42;
- file_header.bfOffBits = sizeof(BitmapFileHeader) + sizeof(BitmapInfoHeader)
- + (sizeof(RGBQuad) * 256);
- file_header.bfSize = file_header.bfOffBits + (pix.x * pix.y);
- file_header.bfReserved1 = 0;
- file_header.bfReserved2 = 0;
-
- info_header.biSize = sizeof(BitmapInfoHeader);
- info_header.biWidth = pix.x;
- info_header.biHeight = pix.y;
- info_header.biPlanes = 1;
- info_header.biBitCount = 8;
- info_header.biCompression = BI_RGB;
- info_header.biSizeImage= pix.x * pix.y;
- info_header.biXPelsPerMeter = 0;
- info_header.biYPelsPerMeter = 0;
- info_header.biClrUsed = 256;
- info_header.biClrImportant = 256;
-
- fwrite( &file_header, sizeof(BitmapFileHeader), 1, fp );
- fwrite( &info_header, sizeof(BitmapInfoHeader), 1, fp );
-
- for(int index = 0; index < 256; index++)
- {
- RGBColor color;
-
- color = pal[ index ];
-
- palette[index].rgbRed = color.red;
- palette[index].rgbGreen = color.green;
- palette[index].rgbBlue = color.blue;
- palette[index].rgbReserved = 0;
- }//end for index that loads the palette
-
- fwrite( palette, sizeof(RGBQuad), 256, fp );
-
- flipVertical();
-
- if ( (info_header.biWidth % 4) == 0 )
- {
- fwrite( mem, info_header.biSizeImage, 1, fp );
- }
- else
- {
- int padding = ((info_header.biWidth / 4 + 1) * 4) - info_header.biWidth;
-
- PIX buffer[10];
- int numRows = pix.y;
-
- //PIX *sPtr = mem;
-
- for (int row = 0; row < numRows; row++)
- {
- fwrite( mem, pix.x, 1, fp );
- fwrite( buffer, padding, 1, fp);
- mem += stride;
- }
- }
-
-
- flipVertical();
- }
-
-// saveBMP
-//--------------------------------------------------------------------------
-int Surface::saveBMP(Palette &pal)
-{
- char strBuf[256];
- int count = 0;
-
- // Incrementally create screen shots.
- for(;;)
- {
- sprintf(strBuf, "shot%04d.bmp", count);
-
- if (UtilInterface::getFileSize(strBuf) <= 0)
- {
- if (!saveBMP(strBuf, pal))
- {
- return false;
- }
-
- return true;
- }
- else
- {
- count++;
- }
-
- }
- return true;
-
-} // end Surface::saveBMP
-
-// saveBMP
-//--------------------------------------------------------------------------
-int Surface::saveBMP( const char *filename, Palette &pal )
-{
- FILE *fp = fopen(filename, "wb");
-
- if (fp == 0) return 0;
-
- saveBMP(fp, pal);
-
- fclose(fp);
-
- return 1;
-
-} // end Surface::saveBMP
+}
// drawWindowsBorder
//--------------------------------------------------------------------------
Index: netpanzer/src/Lib/2D/Surface.hpp
diff -u netpanzer/src/Lib/2D/Surface.hpp:1.6
netpanzer/src/Lib/2D/Surface.hpp:1.7
--- netpanzer/src/Lib/2D/Surface.hpp:1.6 Wed Sep 10 08:32:51 2003
+++ netpanzer/src/Lib/2D/Surface.hpp Fri Sep 12 17:37:10 2003
@@ -251,10 +251,6 @@
inline void bltTransVGradient(const Surface &dest, ColorTable &colorTable)
const { bltTransVGradient(dest, iXY(0, 0), colorTable); }
inline void bltTransVGradient(const Surface &dest, int x, int y,
ColorTable &colorTable) const { bltTransVGradient(dest, iXY(x, y), colorTable);
}
- void bltTransHGradient(const Surface &dest, const iXY &pos, ColorTable
&colorTable) const;
- inline void bltTransHGradient(const Surface &dest, ColorTable &colorTable)
const { bltTransHGradient(dest, iXY(0, 0), colorTable); }
- inline void bltTransHGradient(const Surface &dest, int x, int y,
ColorTable &colorTable) const { bltTransHGradient(dest, iXY(x, y), colorTable);
}
-
void drawHLine(int x1, int y, int x2, const PIX &color) const;
void drawVLine(int x, int y1, int y2, const PIX &color) const;
@@ -400,11 +396,6 @@
int loadRAW(const char *filename, const iXY pix);
void loadRAW(FILE *fp, const iXY pix);
- int saveSUR(const char *filename);
- void saveSUR(FILE *fp);
- int loadSUR(const char *filename);
- void loadSUR(FILE *fp);
-
void scale(const iXY &pix);
inline void scale(int x, int y) { scale(iXY(x, y)); }
inline void scale(int x) { scale(iXY(x, x)); }
@@ -473,13 +464,6 @@
bltStringVGradient(iXY(x, y), string, colorTable);
}
- // Blit a string of text with a horizontal gradient.
- void bltStringHGradient(const iXY &pos, const char *string, ColorTable
&colorTable) const;
- inline void bltStringHGradient(int x, int y, const char *string,
ColorTable &colorTable) const
- {
- bltStringHGradient(iXY(x, y), string, colorTable);
- }
-
// Blit a string of text.
void bltString5x5(const iXY &pos, const char *string, const PIX &color)
const;
@@ -512,14 +496,7 @@
void bltStringCenteredAtPoint(const iXY &pos, const char *string, const
PIX &color) const;
void bltStringCenteredInRect(const iRect &rect, const char *string,
const PIX &color) const;
- int savePCX(Palette &pal);
- void savePCX(FILE *fp, Palette &pal );
- int savePCX( const char *filename, Palette &pal );
-
void loadBMP(const char *fileName, bool needAlloc = true, void
*returnPalette = 0);
- int saveBMP(Palette &pal);
- void saveBMP(FILE *fp, Palette &pal );
- int saveBMP( const char *filename, Palette &pal );
void mapFromPalette(const char* oldPalette);
Index: netpanzer/src/Makefile
diff -u netpanzer/src/Makefile:1.13 netpanzer/src/Makefile:1.14
--- netpanzer/src/Makefile:1.13 Thu Sep 11 14:56:54 2003
+++ netpanzer/src/Makefile Fri Sep 12 17:37:09 2003
@@ -48,3 +48,4 @@
rm -f $(GOAL)
rm -f .depend
+# DO NOT DELETE
Index: netpanzer/src/NetPanzer/Interfaces/ConsoleInterface.cpp
diff -u netpanzer/src/NetPanzer/Interfaces/ConsoleInterface.cpp:1.8
netpanzer/src/NetPanzer/Interfaces/ConsoleInterface.cpp:1.9
--- netpanzer/src/NetPanzer/Interfaces/ConsoleInterface.cpp:1.8 Thu Sep 11
13:35:47 2003
+++ netpanzer/src/NetPanzer/Interfaces/ConsoleInterface.cpp Fri Sep 12
17:37:10 2003
@@ -347,17 +347,17 @@
void ConsoleInterface::addChar(int newChar)
{
// Check if the character should be excluded.
- // Add the character.
- int length = strlen(inputString) + 1;
+ // Add the character.
+ int length = strlen(inputString) + 1;
- inputString[cursorPos] = newChar;
+ inputString[cursorPos] = newChar;
- inputString[length] = '\0';
+ inputString[length] = '\0';
- if (cursorPos < maxCharCount - 1)
- {
- cursorPos++;
- }
+ if (cursorPos < maxCharCount - 1)
+ {
+ cursorPos++;
+ }
} // addChar
void ConsoleInterface::addExtendedChar(int newExtendedChar)
Index: netpanzer/src/NetPanzer/Interfaces/ConsoleInterface.hpp
diff -u netpanzer/src/NetPanzer/Interfaces/ConsoleInterface.hpp:1.3
netpanzer/src/NetPanzer/Interfaces/ConsoleInterface.hpp:1.4
--- netpanzer/src/NetPanzer/Interfaces/ConsoleInterface.hpp:1.3 Wed Sep 10
08:32:54 2003
+++ netpanzer/src/NetPanzer/Interfaces/ConsoleInterface.hpp Fri Sep 12
17:37:10 2003
@@ -39,8 +39,8 @@
enum { _console_overlap, _console_full };
class ConsoleInterface
- {
- protected:
+{
+protected:
static FILE *con_file;
static bool log_file_active;
static bool stdout_pipe;
@@ -64,8 +64,7 @@
static char inputPrompt[256];
static int cursorPos;
- public:
-
+public:
static void initialize( long size );
static void setToSurfaceSize( iXY pix );
@@ -81,18 +80,12 @@
static void postMessage( const char *format, ... );
- static void printf( const char *format, ... );
-
/* Input String Methods */
static void setInputStringStatus( bool on_off );
static void resetInputString( char *prompt );
static void addChar(int newChar);
static void addExtendedChar(int newExtendedChar);
static void getInputString( char *string );
-
-
- };
-
-
+};
#endif // ** _CONSOLEINTERFACE_HPP
Index: netpanzer/src/NetPanzer/Interfaces/GameManager.cpp
diff -u netpanzer/src/NetPanzer/Interfaces/GameManager.cpp:1.36
netpanzer/src/NetPanzer/Interfaces/GameManager.cpp:1.37
--- netpanzer/src/NetPanzer/Interfaces/GameManager.cpp:1.36 Fri Sep 12
10:12:45 2003
+++ netpanzer/src/NetPanzer/Interfaces/GameManager.cpp Fri Sep 12 17:37:10 2003
@@ -1859,55 +1859,45 @@
// ******************************************************************
void GameManager::graphicsLoop()
- {
- FRAME_BUFFER.lock();
- screen.lock(FRAME_BUFFER.mem);
+{
+ FRAME_BUFFER.lock();
+ screen.lock(FRAME_BUFFER.mem);
- Desktop::draw();
+ Desktop::draw();
- FontSystem2D::drawAll();
+ FontSystem2D::drawAll();
- if ( KeyboardInterface::getKeyPressed( SDLK_F9 ) )
- {
- Palette pal;
- if (!screen.saveBMP(pal) )
- { ConsoleInterface::postMessage("Error taking screen shot."); }
- else
- { /* ConsoleInterface::postMessage("Screen shot taken."); */ }
- }
-
- char strBuf[256];
+ char strBuf[256];
- if (display_frame_rate_flag == true)
- {
- sprintf(strBuf, "%3.1f : %3.1f" , TimerInterface::getFPS(),
TimerInterface::getFPSAvg());
- screen.bltString5x5(iXY(2, 2), strBuf, Color::white);
- }
+ if (display_frame_rate_flag == true)
+ {
+ sprintf(strBuf, "%3.1f : %3.1f" , TimerInterface::getFPS(),
TimerInterface::getFPSAvg());
+ screen.bltString5x5(iXY(2, 2), strBuf, Color::white);
+ }
- if (display_network_info_flag == true)
- {
- sprintf(strBuf, "|| %.4f : %.4f || %.4f : %.4f ||" ,
NetworkState::packets_sent_per_sec, NetworkState::bytes_sent_per_sec,
-
NetworkState::packets_received_per_sec, NetworkState::bytes_received_per_sec );
- screen.bltString5x5(iXY(60, 2), strBuf, Color::white);
- }
-
- if (Desktop::getVisible("GameView"))
- { ConsoleInterface::update( FRAME_BUFFER ); }
-
- mouse.draw(screen);
-
- //char strBuf[256];
- //sprintf(strBuf, "%d, %d", mouse.getScreenPos().x, mouse.getScreenPos().y);
- //screen.bltString(40, 2, strBuf, Color::white);
+ if (display_network_info_flag == true)
+ {
+ sprintf(strBuf, "|| %.4f : %.4f || %.4f : %.4f ||" ,
NetworkState::packets_sent_per_sec, NetworkState::bytes_sent_per_sec,
+ NetworkState::packets_received_per_sec,
NetworkState::bytes_received_per_sec );
+ screen.bltString5x5(iXY(60, 2), strBuf, Color::white);
+ }
+
+ if (Desktop::getVisible("GameView"))
+ { ConsoleInterface::update( FRAME_BUFFER ); }
+
+ mouse.draw(screen);
+
+ //char strBuf[256];
+ //sprintf(strBuf, "%d, %d", mouse.getScreenPos().x,
mouse.getScreenPos().y);
+ //screen.bltString(40, 2, strBuf, Color::white);
- MouseInterface::updateCursor();
+ MouseInterface::updateCursor();
- FRAME_BUFFER.unlock();
- screen.unlock();
-
- Screen->copyDoubleBufferandFlip();
+ FRAME_BUFFER.unlock();
+ screen.unlock();
- }
+ Screen->copyDoubleBufferandFlip();
+}
// ******************************************************************
void GameManager::dedicatedGameLoop()
Index: netpanzer/src/NetPanzer/Views/Game/GameTemplateView.cpp
diff -u netpanzer/src/NetPanzer/Views/Game/GameTemplateView.cpp:1.4
netpanzer/src/NetPanzer/Views/Game/GameTemplateView.cpp:1.5
--- netpanzer/src/NetPanzer/Views/Game/GameTemplateView.cpp:1.4 Fri Sep 5
22:01:19 2003
+++ netpanzer/src/NetPanzer/Views/Game/GameTemplateView.cpp Fri Sep 12
17:37:10 2003
@@ -15,9 +15,8 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-
-
#include <config.h>
+
#include "GameTemplateView.hpp"
#include "Desktop.hpp"
#include "GameViewGlobals.hpp"
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [netPanzer-CVS] netpanzer/src ChangeLog Makefile Lib/2D/Surface...,
Matthias Braun <=