[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[netPanzer-CVS] netpanzer/src Makefile Lib/2D/Span.cpp Lib/Part...
From: |
Matthias Braun |
Subject: |
[netPanzer-CVS] netpanzer/src Makefile Lib/2D/Span.cpp Lib/Part... |
Date: |
Mon, 08 Sep 2003 08:12:20 -0400 |
CVSROOT: /cvsroot/netpanzer
Module name: netpanzer
Branch:
Changes by: Matthias Braun <address@hidden> 03/09/08 08:12:19
Modified files:
src : Makefile
src/Lib/2D : Span.cpp
src/Lib/Particles: ParticleInterface.cpp
src/NetPanzer/Classes: TileEngine.cpp TileEngine.hpp TileSet.cpp
TileSet.hpp ViewCamera.cpp ViewCamera.hpp
src/NetPanzer/Core/unix: main.cpp
src/NetPanzer/Interfaces: GameManager.cpp MapInterface.hpp
WorldViewInterface.hpp
src/NetPanzer/Port: Gdatstct.hpp Wrldsprt.hpp blitters.cpp
blitters.h
src/UILib : Sound.hpp UIDraw.hpp
src/UILib/SDL : SDLDraw.cpp SDLSound.cpp SDLSound.hpp
Log message:
-fixed some small bugs in blitters.cpp
-reenabled the TileEngine::Draw code
=> The map is drawn ingame now (though the last line often is wrong for
some
reason...)
Patches:
Index: netpanzer/src/Lib/2D/Span.cpp
diff -u netpanzer/src/Lib/2D/Span.cpp:1.4 netpanzer/src/Lib/2D/Span.cpp:1.5
--- netpanzer/src/Lib/2D/Span.cpp:1.4 Sun Sep 7 22:44:22 2003
+++ netpanzer/src/Lib/2D/Span.cpp Mon Sep 8 08:12:18 2003
@@ -297,8 +297,7 @@
if (!allowSpanBlitting) { return; } // Remove for release candidate.
- int idx;
-
+ int idx;
for(idx=0;idx<pixelsPerRow;idx++)
dRow[idx] = table[dRow[idx]];
Index: netpanzer/src/Lib/Particles/ParticleInterface.cpp
diff -u netpanzer/src/Lib/Particles/ParticleInterface.cpp:1.3
netpanzer/src/Lib/Particles/ParticleInterface.cpp:1.4
--- netpanzer/src/Lib/Particles/ParticleInterface.cpp:1.3 Fri Sep 5
22:01:18 2003
+++ netpanzer/src/Lib/Particles/ParticleInterface.cpp Mon Sep 8 08:12:18 2003
@@ -458,7 +458,9 @@
float randomness = 1.0f; //Particle2D::getScale(0.8f, 0.4f);
float frameRateAdjustment = getFrameRateAdjustment();
- e.particleCount = 8 * (frameRateAdjustment *
float(unitHitPointTable[unitState.unit_type]) * randomness);
+ e.particleCount = (int) (
+ 8 * (frameRateAdjustment *
+ float(unitHitPointTable[unitState.unit_type]) *
randomness));
if (gDrawExplosionParticleCount)
{
Index: netpanzer/src/Makefile
diff -u netpanzer/src/Makefile:1.10 netpanzer/src/Makefile:1.11
--- netpanzer/src/Makefile:1.10 Sun Sep 7 10:04:47 2003
+++ netpanzer/src/Makefile Mon Sep 8 08:12:18 2003
@@ -20,7 +20,7 @@
DIRS += NetPanzer/Interfaces/unix Stub UILib/SDL UILib/Network \
NetPanzer/Core/unix
GOAL = ../netpanzer
-LINKFLAGS += -g3 `sdl-config --libs` -lSDL_net
+LINKFLAGS += -g3 `sdl-config --libs` -lSDL_net -lSDL_mixer
CFLAGS += `sdl-config --cflags` -DUNIX
endif
ifeq ($(SYSTEM),WIN32)
Index: netpanzer/src/NetPanzer/Classes/TileEngine.cpp
diff -u netpanzer/src/NetPanzer/Classes/TileEngine.cpp:1.5
netpanzer/src/NetPanzer/Classes/TileEngine.cpp:1.6
--- netpanzer/src/NetPanzer/Classes/TileEngine.cpp:1.5 Sat Sep 6 17:05:26 2003
+++ netpanzer/src/NetPanzer/Classes/TileEngine.cpp Mon Sep 8 08:12:19 2003
@@ -16,276 +16,246 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <config.h>
+
#include "TileEngine.hpp"
#include "blitters.h"
#include "DDHardSurface.hpp"
+#include "UILib/UIDraw.hpp"
-void TileEngine::blitWorld( void )
+void TileEngine::blitWorld()
{
- // XXX disabled for now until the assembler blitters are converted
- // and the global vars (DBUFFER_VIEW_WIDTH, ...) are implemented
-#if 0
- unsigned long x_left_length, x_left_offset, x_right_length, x_right_offset;
- unsigned long y_top_length, y_top_offset, y_bottom_length, y_bottom_offset;
- bool x_right_end_flag, y_bottom_end_flag;
-
- unsigned short map_x, map_y;
- unsigned long world_x, world_y;
+ unsigned long x_left_length, x_left_offset, x_right_length,
x_right_offset;
+ unsigned long y_top_length, y_top_offset, y_bottom_length,
y_bottom_offset;
+ bool x_right_end_flag = false, y_bottom_end_flag = false;
- unsigned char *tile_offset,
- *buffer_offset;
+ unsigned short map_x, map_y;
+ unsigned long world_x, world_y;
-
- unsigned long i,k;
+ unsigned char *tile_offset, *buffer_offset;
- unsigned char *double_buffer;
+ unsigned long i,k;
- MapElementType *map_buffer;
- MapElementType *world_row;
- MapElementType tile_type;
+ unsigned char *double_buffer;
- unsigned short map_width;
- unsigned short map_height;
+ MapElementType *map_buffer;
+ MapElementType *world_row;
+ MapElementType tile_type;
- unsigned long next_map_row_offset;
- unsigned long next_tile_row_offset;
- unsigned long tile_size;
+ unsigned short map_width;
+ unsigned short map_height;
- unsigned long complete_columns;
- unsigned long complete_rows;
+ unsigned long next_map_row_offset;
+ unsigned long next_tile_row_offset;
+ unsigned long tile_size;
+ unsigned long complete_columns;
+ unsigned long complete_rows;
- tile_size = tile_set.getTileXsize();
+ tile_size = tile_set.getTileXsize();
- // XXX
- // main_camera->getViewStart( DBUFFER_VIEW_WIDTH, DBUFFER_VIEW_HEIGHT,
- // &world_x, &world_y);
-
- pointXYtoMapXY( world_x, world_y, &map_x, &map_y );
+ main_camera->getViewStart(Screen->getWidth(), Screen->getHeight(),
+ &world_x, &world_y);
+ pointXYtoMapXY( world_x, world_y, &map_x, &map_y );
+ map_width = main_map.getXsize();
- map_width = main_map.getXsize();
+ map_height = main_map.getYsize();
- map_height = main_map.getYsize();
+ main_map.getRawMapBuffer( &map_buffer );
- main_map.getRawMapBuffer( &map_buffer );
+ double_buffer = (unsigned char*) FRAME_BUFFER.mem;
- double_buffer = FRAME_BUFFER.mem;
- /*
- x_offset = (world_x % tile_size );
- y_offset = (world_y % tile_size );
-
- x_length = tile_size - x_offset;
- y_length = tile_size - y_offset;
- */
+ /*
+ x_offset = (world_x % tile_size );
+ y_offset = (world_y % tile_size );
+
+ x_length = tile_size - x_offset;
+ y_length = tile_size - y_offset;
+ */
- x_left_offset = (world_x % tile_size);
- x_left_length = (tile_size - x_left_offset);
-
- // XXX
- // complete_columns = (DBUFFER_VIEW_WIDTH - x_left_length) / tile_size;
-
- x_right_offset = 0;
- // XXX
- //x_right_length = (DBUFFER_VIEW_WIDTH - x_left_length) % tile_size;
- if ( x_right_length > 0 )
- x_right_end_flag = true;
+ x_left_offset = (world_x % tile_size);
+ x_left_length = (tile_size - x_left_offset);
+ complete_columns = (Screen->getWidth() - x_left_length) / tile_size;
- y_top_offset = (world_y % tile_size);
- y_top_length = (tile_size - y_top_offset);
+ x_right_offset = 0;
+ x_right_length = (Screen->getWidth() - x_left_length) % tile_size;
+ if ( x_right_length > 0 )
+ x_right_end_flag = true;
- // XXX
- // complete_rows = (DBUFFER_VIEW_HEIGHT - y_top_length) / tile_size;
+ y_top_offset = (world_y % tile_size);
+ y_top_length = (tile_size - y_top_offset);
- y_bottom_offset = 0;
- // XXX
- // y_bottom_length = (DBUFFER_VIEW_HEIGHT - y_top_length) % tile_size;
- if ( y_bottom_length > 0 )
- y_bottom_end_flag = true;
+ complete_rows = (Screen->getHeight() - y_top_length) / tile_size;
- world_row = map_buffer + (map_y * map_width) + map_x;
+ y_bottom_offset = 0;
+ y_bottom_length = (Screen->getHeight() - y_top_length) % tile_size;
+ if ( y_bottom_length > 0 )
+ y_bottom_end_flag = true;
- // XXX
- //next_tile_row_offset = DBUFFER_WIDTH * (tile_size - 1) + X_CLIP_OFS;
+ world_row = map_buffer + (map_y * map_width) + map_x;
- next_map_row_offset = map_width - complete_columns - 1;
+ // XXX
+ next_tile_row_offset = Screen->getWidth() * (tile_size - 1) +
X_CLIP_OFS;
- // THE TOP ROW
+ next_map_row_offset = map_width - complete_columns - 1;
- tile_type = *(world_row);
+ // THE TOP ROW
- tile_offset = tile_set.getTile( tile_type );
- tile_offset = tile_offset + (y_top_offset * tile_size ) + x_left_offset;
+ tile_type = *(world_row);
+
+ tile_offset = tile_set.getTile( tile_type );
+ tile_offset = tile_offset + (y_top_offset * tile_size ) +
x_left_offset;
- // XXX
- //buffer_offset = double_buffer + OFFSET_TO_VIEW;
+ // XXX is this correct?
+ buffer_offset = double_buffer /*+ OFFSET_TO_VIEW*/;
- blit_partial_xy( tile_offset, buffer_offset, y_top_length, x_left_length );
+ blit_partial_xy( tile_offset, buffer_offset, y_top_length,
x_left_length );
- world_row++;
+ world_row++;
- tile_type = *(world_row);
+ tile_type = *(world_row);
- tile_offset = tile_set.getTile( tile_type );
- tile_offset = tile_offset + (y_top_offset * tile_size );
+ tile_offset = tile_set.getTile( tile_type );
+ tile_offset = tile_offset + (y_top_offset * tile_size );
- buffer_offset += x_left_length;
+ buffer_offset += x_left_length;
+
+ for( i=0; i < complete_columns; i++ )
+ {
+ blit_partial_y( tile_offset, buffer_offset, y_top_length );
- for( i=0; i < complete_columns; i++ )
- {
- blit_partial_y( tile_offset, buffer_offset, y_top_length );
+ world_row++;
- world_row++;
+ tile_type = *(world_row);
- tile_type = *(world_row);
+ tile_offset = tile_set.getTile( tile_type );
+ tile_offset = tile_offset + (y_top_offset * tile_size );
- tile_offset = tile_set.getTile( tile_type );
- tile_offset = tile_offset + (y_top_offset * tile_size );
+ buffer_offset += tile_size;
+ }
- buffer_offset += tile_size;
-
- }
-
- if( x_right_end_flag == true )
- {
+ if( x_right_end_flag == true )
+ {
- if (y_top_length > 0 && x_right_length > 0)
- {
- blit_partial_xy(tile_offset, buffer_offset, y_top_length,
x_right_length);
- }
-
- // XXX
- //buffer_offset += ( DBUFFER_WIDTH * (y_top_length-1)) + X_CLIP_OFS +
x_right_length;
-
- world_row = world_row + next_map_row_offset;
- }
- else
- {
- // XXX
- //buffer_offset += (DBUFFER_WIDTH * (y_top_length-1)) + X_CLIP_OFS;
-
- world_row = world_row + next_map_row_offset;
- }
-
- // THE MIDDLE ROWS
-
-for( k=0; k < complete_rows; k++)
-{
-
- tile_type = *(world_row);
-
- tile_offset = tile_set.getTile( tile_type );
- tile_offset = tile_offset + x_left_offset;
-
- blit_partial_xy( tile_offset, buffer_offset, tile_size, x_left_length);
-
-
- world_row++;
-
- tile_type = *(world_row);
-
- tile_offset = tile_set.getTile( tile_type );
-
- buffer_offset += x_left_length;
-
- for( i=0; i < complete_columns; i++ )
- {
- blit_partial_y( tile_offset, buffer_offset, tile_size );
-
- world_row++;
-
- tile_type = *(world_row);
-
- tile_offset = tile_set.getTile( tile_type );
-
- buffer_offset += tile_size;
- }
-
-
- if( x_right_end_flag == true )
- {
- if (tile_size > 0 && x_right_length > 0)
- {
- blit_partial_xy( tile_offset, buffer_offset, tile_size, x_right_length );
- }
-
- buffer_offset += next_tile_row_offset + x_right_length;
-
- world_row = world_row + next_map_row_offset;
- }
- else
- {
- buffer_offset += next_tile_row_offset;
+ if (y_top_length > 0 && x_right_length > 0)
+ {
+ blit_partial_xy(tile_offset, buffer_offset,
y_top_length, x_right_length);
+ }
- world_row = world_row + next_map_row_offset;
- }
+ // XXX
+ buffer_offset += ( Screen->getWidth() * (y_top_length-1)) +
X_CLIP_OFS + x_right_length;
-}
+ world_row = world_row + next_map_row_offset;
+ }
+ else
+ {
+ // XXX
+ //buffer_offset += (Screen->getWidth() * (y_top_length-1)) +
X_CLIP_OFS;
+
+ world_row = world_row + next_map_row_offset;
+ }
+
+ // THE MIDDLE ROWS
+
+ for( k=0; k < complete_rows; k++)
+ {
+
+ tile_type = *(world_row);
+
+ tile_offset = tile_set.getTile( tile_type );
+ tile_offset = tile_offset + x_left_offset;
+
+ blit_partial_xy( tile_offset, buffer_offset, tile_size,
x_left_length);
+
+ world_row++;
+ tile_type = *(world_row);
+ tile_offset = tile_set.getTile( tile_type );
+ buffer_offset += x_left_length;
+
+ for( i=0; i < complete_columns; i++ )
+ {
+ blit_partial_y( tile_offset, buffer_offset, tile_size );
+
+ world_row++;
+ tile_type = *(world_row);
+ tile_offset = tile_set.getTile( tile_type );
+ buffer_offset += tile_size;
+ }
+
+ if( x_right_end_flag == true )
+ {
+ if (tile_size > 0 && x_right_length > 0)
+ {
+ blit_partial_xy( tile_offset, buffer_offset,
tile_size, x_right_length );
+ }
- // NOW THE LAST ROW IF NEEDED
+ buffer_offset += next_tile_row_offset + x_right_length;
- if( y_bottom_end_flag == true )
- {
+ world_row = world_row + next_map_row_offset;
+ }
+ else
+ {
+ buffer_offset += next_tile_row_offset;
- tile_type = *(world_row);
+ world_row = world_row + next_map_row_offset;
+ }
- tile_offset = tile_set.getTile( tile_type );
- tile_offset = tile_offset + x_left_offset;
+ }
- if (y_bottom_length > 0 && x_left_length > 0)
- {
- blit_partial_xy( tile_offset, buffer_offset, y_bottom_length,
x_left_length );
- }
+ // NOW THE LAST ROW IF NEEDED
+ if( y_bottom_end_flag == true )
+ {
+ tile_type = *(world_row);
+ tile_offset = tile_set.getTile( tile_type );
+ tile_offset = tile_offset + x_left_offset;
- world_row++;
+ if (y_bottom_length > 0 && x_left_length > 0)
+ {
+ blit_partial_xy( tile_offset, buffer_offset,
y_bottom_length, x_left_length );
+ }
- tile_type = *(world_row);
+ world_row++;
- tile_offset = tile_set.getTile( tile_type );
+ tile_type = *(world_row);
- buffer_offset += x_left_length;
+ tile_offset = tile_set.getTile( tile_type );
+ buffer_offset += x_left_length;
- for( i=0; i < complete_columns; i++ )
- {
- if (y_bottom_length > 0)
+ for( i=0; i < complete_columns; i++ )
{
- blit_partial_y( tile_offset, buffer_offset,
y_bottom_length );
+ if (y_bottom_length > 0)
+ {
+ blit_partial_y( tile_offset, buffer_offset,
y_bottom_length );
+ }
+ world_row++;
+
+ tile_type = *(world_row);
+ tile_offset = tile_set.getTile( tile_type );
+ buffer_offset += tile_size;
}
- world_row++;
-
- tile_type = *(world_row);
-
- tile_offset = tile_set.getTile( tile_type );
-
- buffer_offset += tile_size;
+ if( x_right_end_flag == true )
+ {
+ if (y_bottom_length > 0 && x_right_length > 0)
+ {
+ blit_partial_xy( tile_offset, buffer_offset,
y_bottom_length, x_right_length );
+ }
- }
+ // XXX
+ buffer_offset += (Screen->getWidth() *
(y_bottom_length-1)) + X_CLIP_OFS + x_right_length;
- if( x_right_end_flag == true )
- {
- if (y_bottom_length > 0 && x_right_length > 0)
- {
- blit_partial_xy( tile_offset, buffer_offset,
y_bottom_length, x_right_length );
+ world_row = world_row + next_map_row_offset;
}
+ else
+ {
+ // XXX
+ buffer_offset += (Screen->getWidth() *
(y_bottom_length-1)) + X_CLIP_OFS;
- // XXX
- // buffer_offset += (DBUFFER_WIDTH * (y_bottom_length-1)) + X_CLIP_OFS +
x_right_length;
-
- world_row = world_row + next_map_row_offset;
- }
- else
- {
- // XXX
- // buffer_offset += (DBUFFER_WIDTH * (y_bottom_length-1)) + X_CLIP_OFS;
-
- world_row = world_row + next_map_row_offset;
- }
-
- }
-#endif
- }
+ world_row = world_row + next_map_row_offset;
+ }
+ }
+}
Index: netpanzer/src/NetPanzer/Classes/TileEngine.hpp
diff -u netpanzer/src/NetPanzer/Classes/TileEngine.hpp:1.1
netpanzer/src/NetPanzer/Classes/TileEngine.hpp:1.2
--- netpanzer/src/NetPanzer/Classes/TileEngine.hpp:1.1 Sun Dec 1 12:51:51 2002
+++ netpanzer/src/NetPanzer/Classes/TileEngine.hpp Mon Sep 8 08:12:19 2003
@@ -23,13 +23,9 @@
#include "TileInterface.hpp"
class TileEngine : private WorldViewInterface, private MapInterface
- {
-
- public:
- static void blitWorld( void );
-
-
-
- };
+{
+public:
+ static void blitWorld( void );
+};
#endif // ** _TILEENGINE_HPP
Index: netpanzer/src/NetPanzer/Classes/TileSet.cpp
diff -u netpanzer/src/NetPanzer/Classes/TileSet.cpp:1.3
netpanzer/src/NetPanzer/Classes/TileSet.cpp:1.4
--- netpanzer/src/NetPanzer/Classes/TileSet.cpp:1.3 Sat Sep 6 14:18:13 2003
+++ netpanzer/src/NetPanzer/Classes/TileSet.cpp Mon Sep 8 08:12:19 2003
@@ -143,7 +143,7 @@
tile_info = new TILE_HEADER [ tile_set_info.tile_count ];
assert( tile_info != 0 );
- tile_data = new unsigned char [ tile_buffer_size ];
+ tile_data = new unsigned char[tile_buffer_size];
assert( tile_data != 0 );
fread( tile_info, tile_set_info.tile_count, sizeof(TILE_HEADER), infile );
@@ -225,7 +225,7 @@
tile_buffer_size = (tile_set_info.x_pix * tile_set_info.y_pix) *
mapping_table.used_tile_count;
tile_size = (tile_set_info.x_pix * tile_set_info.y_pix);
- tile_data = new unsigned char [ tile_buffer_size ];
+ tile_data = new unsigned char [tile_buffer_size];
assert( tile_data != 0 );
mapped_index = 0;
@@ -405,7 +405,7 @@
tile_buffer_size = (tile_set_info.x_pix * tile_set_info.y_pix) *
mapping_table.used_tile_count;
TileSet::tile_size = tile_size = (tile_set_info.x_pix * tile_set_info.y_pix);
- tile_data = new unsigned char [ tile_buffer_size ];
+ tile_data = new unsigned char [tile_buffer_size];
assert( tile_data != 0 );
partition_load_tile_index = 0;
Index: netpanzer/src/NetPanzer/Classes/TileSet.hpp
diff -u netpanzer/src/NetPanzer/Classes/TileSet.hpp:1.2
netpanzer/src/NetPanzer/Classes/TileSet.hpp:1.3
--- netpanzer/src/NetPanzer/Classes/TileSet.hpp:1.2 Mon Sep 1 16:24:20 2003
+++ netpanzer/src/NetPanzer/Classes/TileSet.hpp Mon Sep 8 08:12:19 2003
@@ -23,66 +23,59 @@
#include "WadMapTable.hpp"
class TileSet : virtual PObject
- {
- protected:
- bool tile_set_loaded;
- TILE_DBASE_HEADER tile_set_info;
- TILE_HEADER *tile_info;
- unsigned char *tile_data;
+{
+protected:
+ bool tile_set_loaded;
+ TILE_DBASE_HEADER tile_set_info;
+ TILE_HEADER *tile_info;
+ unsigned char *tile_data;
- unsigned long tile_size;
- unsigned long tile_count;
- void computeTileConsts( void );
-
- int partition_load_fhandle;
- unsigned long partition_load_partition_count;
- unsigned long partition_load_tile_index;
- unsigned long partition_load_mapped_index;
+ unsigned long tile_size;
+ unsigned long tile_count;
+ void computeTileConsts( void );
+
+ int partition_load_fhandle;
+ unsigned long partition_load_partition_count;
+ unsigned long partition_load_tile_index;
+ unsigned long partition_load_mapped_index;
- public:
-
- TileSet( );
+public:
+ TileSet( );
- void loadTileSetInfo( const char *file_path );
-
- void loadTileSetInfo( const char *file_path, WadMapTable &mapping_table );
-
- void loadTileSet( const char *file_path, WadMapTable &mapping_table );
+ void loadTileSetInfo( const char *file_path );
+ void loadTileSetInfo( const char *file_path, WadMapTable &mapping_table
);
+ void loadTileSet( const char *file_path, WadMapTable &mapping_table );
- bool startPartitionTileSetLoad( const char *file_path, WadMapTable
&mapping_table, unsigned long partitions );
- bool partitionTileSetLoad( WadMapTable &mapping_table, int
*percent_complete );
-
- void loadTileSet( const char *file_path );
-
- inline unsigned char * getTile( unsigned long index )
- { return( tile_data + (index * tile_size) ); }
-
- inline unsigned short getTileXsize( void )
- { return ( tile_set_info.x_pix ); }
-
- inline unsigned short getTileYsize( void )
- { return ( tile_set_info.y_pix ); }
-
- inline unsigned short getTileCount( void )
- { return ( tile_set_info.tile_count ); }
+ bool startPartitionTileSetLoad( const char *file_path, WadMapTable
&mapping_table, unsigned long partitions );
+ bool partitionTileSetLoad( WadMapTable &mapping_table, int
*percent_complete );
- inline unsigned char getAverageTileColor( unsigned long index )
+ void loadTileSet( const char *file_path );
+ inline unsigned char * getTile(unsigned long index) const
+ { return( tile_data + (index * tile_size) ); }
+ inline unsigned short getTileXsize() const
+ { return ( tile_set_info.x_pix ); }
+ inline unsigned short getTileYsize() const
+ { return ( tile_set_info.y_pix ); }
+ inline unsigned short getTileCount() const
+ { return ( tile_set_info.tile_count ); }
+ inline unsigned char getAverageTileColor(unsigned long index) const
{
- return( tile_info[ index ].avg_color );
- }
-
- inline char getTileMovementValue( unsigned long index )
- {
- return( tile_info[ index ].move_value );
- }
+ return( tile_info[ index ].avg_color );
+ }
- inline unsigned char getTilePixel( unsigned long index , unsigned int pixX,
unsigned int pixY)
- {
- if( index < tile_count )
- { return( *(getTile(index) + (pixY * getTileXsize()) + pixX)); }
+ inline char getTileMovementValue( unsigned long index )
+ {
+ return( tile_info[ index ].move_value );
+ }
+
+ inline unsigned char getTilePixel( unsigned long index , unsigned int
pixX,
+ unsigned int pixY)
+ {
+ if( index < tile_count )
+ { return( *(getTile(index) + (pixY * getTileXsize()) + pixX)); }
- return( 0 );
- }
+ return( 0 );
+ }
/*
inline unsigned char getTilePixel( long *index , unsigned int pixX,
unsigned int pixY)
@@ -94,6 +87,6 @@
return( 0 );
}
*/
- };
+};
#endif // ** _TILESET_HPP
Index: netpanzer/src/NetPanzer/Classes/ViewCamera.cpp
diff -u netpanzer/src/NetPanzer/Classes/ViewCamera.cpp:1.3
netpanzer/src/NetPanzer/Classes/ViewCamera.cpp:1.4
--- netpanzer/src/NetPanzer/Classes/ViewCamera.cpp:1.3 Fri Sep 5 22:01:18 2003
+++ netpanzer/src/NetPanzer/Classes/ViewCamera.cpp Mon Sep 8 08:12:19 2003
@@ -93,35 +93,36 @@
void ViewCamera::getViewStart( unsigned long view_size_x, unsigned long
view_size_y,
unsigned long *view_start_x, unsigned long
*view_start_y )
- {
- PointXYi map_size;
- unsigned long view_offset_x;
- unsigned long view_offset_y;
- long start_x, start_y;
+{
+ PointXYi map_size;
+ unsigned long view_offset_x;
+ unsigned long view_offset_y;
+ long start_x, start_y;
- view_offset_x = view_size_x >> 1;
- view_offset_y = view_size_y >> 1;
+ view_offset_x = view_size_x >> 1;
+ view_offset_y = view_size_y >> 1;
- start_x = loc.x - view_offset_x;
- start_y = loc.y - view_offset_y;
+ start_x = loc.x - view_offset_x;
+ start_y = loc.y - view_offset_y;
- getMapPointSize( &map_size );
+ getMapPointSize( &map_size );
- if ( start_x < 0 )
- start_x = 0;
+ if ( start_x < 0 )
+ start_x = 0;
- if ( start_y < 0 )
- start_y = 0;
+ if ( start_y < 0 )
+ start_y = 0;
- if ( (start_x + view_size_x) > map_size.x )
- start_x = (map_size.x - view_size_x) ;
+ if ( (start_x + view_size_x) > map_size.x )
+ start_x = (map_size.x - view_size_x) ;
- if ( (start_y + view_size_y) > map_size.y )
- start_y = (map_size.y - view_size_y);
+ if ( (start_y + view_size_y) > map_size.y )
+ start_y = (map_size.y - view_size_y);
- loc.x = start_x + view_offset_x;
- loc.y = start_y + view_offset_y;
+ loc.x = start_x + view_offset_x;
+ loc.y = start_y + view_offset_y;
+
+ *view_start_x = start_x;
+ *view_start_y = start_y;
+}
- *view_start_x = start_x;
- *view_start_y = start_y;
- }
Index: netpanzer/src/NetPanzer/Classes/ViewCamera.hpp
diff -u netpanzer/src/NetPanzer/Classes/ViewCamera.hpp:1.2
netpanzer/src/NetPanzer/Classes/ViewCamera.hpp:1.3
--- netpanzer/src/NetPanzer/Classes/ViewCamera.hpp:1.2 Mon Sep 1 16:24:20 2003
+++ netpanzer/src/NetPanzer/Classes/ViewCamera.hpp Mon Sep 8 08:12:19 2003
@@ -23,47 +23,46 @@
#include "Point.hpp"
class ViewCamera : private MapInterface
- {
- protected:
- PointXYi loc;
- PointXYi view_size;
+{
+protected:
+ PointXYi loc;
+ PointXYi view_size;
- public:
- ViewCamera();
- void scrollPlusX( long scroll_increment );
- void scrollMinusX( long scroll_increment );
- void scrollMinusY( long scroll_increment );
- void scrollPlusY( long scroll_increment );
+public:
+ ViewCamera();
+ void scrollPlusX( long scroll_increment );
+ void scrollMinusX( long scroll_increment );
+ void scrollMinusY( long scroll_increment );
+ void scrollPlusY( long scroll_increment );
- inline void setCamera( const PointXYi &new_loc )
- {
- loc.x = new_loc.x - (new_loc.x % 4);
- loc.y = new_loc.y - (new_loc.y % 4);
+ inline void setCamera( const PointXYi &new_loc )
+ {
+ loc.x = new_loc.x - (new_loc.x % 4);
+ loc.y = new_loc.y - (new_loc.y % 4);
}
- inline void setCameraSize( const PointXYi &size )
- {
- view_size = size;
+ inline void setCameraSize( const PointXYi &size )
+ {
+ view_size = size;
}
- void getViewStart( unsigned long view_size_x, unsigned long view_size_y,
- unsigned long *view_start_x, unsigned long *view_start_y
);
+ void getViewStart( unsigned long view_size_x, unsigned long view_size_y,
+ unsigned long *view_start_x, unsigned long
*view_start_y );
- inline void getViewWindow( Recti *view_win )
- {
- unsigned long view_start_x, view_start_y;
- getViewStart( view_size.x, view_size.y, &view_start_x, &view_start_y );
- view_win->min.x = view_start_x;
- view_win->min.y = view_start_y;
- view_win->max.x = view_start_x + view_size.x;
- view_win->max.y = view_start_y + view_size.y;
+ inline void getViewWindow( Recti *view_win )
+ {
+ unsigned long view_start_x, view_start_y;
+ getViewStart( view_size.x, view_size.y, &view_start_x,
&view_start_y );
+ view_win->min.x = view_start_x;
+ view_win->min.y = view_start_y;
+ view_win->max.x = view_start_x + view_size.x;
+ view_win->max.y = view_start_y + view_size.y;
}
- inline long getCameraDistance( const PointXYi &world_loc )
- {
- return( (long) (loc - world_loc).mag2() );
+ inline long getCameraDistance( const PointXYi &world_loc )
+ {
+ return( (long) (loc - world_loc).mag2() );
}
- };
-
+};
#endif // ** _VIEWCAMERA_HPP
Index: netpanzer/src/NetPanzer/Core/unix/main.cpp
diff -u netpanzer/src/NetPanzer/Core/unix/main.cpp:1.5
netpanzer/src/NetPanzer/Core/unix/main.cpp:1.6
--- netpanzer/src/NetPanzer/Core/unix/main.cpp:1.5 Sat Sep 6 18:31:20 2003
+++ netpanzer/src/NetPanzer/Core/unix/main.cpp Mon Sep 8 08:12:19 2003
@@ -18,6 +18,7 @@
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
+#include <time.h>
#include <SDL.h>
#include "Log.hpp"
@@ -29,10 +30,12 @@
int main(int argc, char** argv)
{
- SDL_Init(SDL_INIT_TIMER
- | SDL_INIT_VIDEO
- /*| SDL_INIT_AUDIO*/
- );
+ SDL_Init(SDL_INIT_TIMER);
+ srand(time(0));
+#ifdef __USE_SVID
+ // the STL functions seem to use the 48er versions of the random
generator
+ srand48(time(0));
+#endif
LOG( ("Starting GameManager initialisation.") );
// XXX hacky hack... needs changes in GameManager I think...
Index: netpanzer/src/NetPanzer/Interfaces/GameManager.cpp
diff -u netpanzer/src/NetPanzer/Interfaces/GameManager.cpp:1.24
netpanzer/src/NetPanzer/Interfaces/GameManager.cpp:1.25
--- netpanzer/src/NetPanzer/Interfaces/GameManager.cpp:1.24 Sun Sep 7
22:44:22 2003
+++ netpanzer/src/NetPanzer/Interfaces/GameManager.cpp Mon Sep 8 08:12:19 2003
@@ -220,12 +220,9 @@
LOG( ("Initialize sound system.") );
sound = new SDLSound();
#endif
- if (!sound || !sound->initialize())
- {
- LOG( ( "Failed to initialize the Sound Sub-system" ) );
- delete sound;
- sound = 0;
- }
+
+ // start some music
+ sound->playMusic("sfx/music/");
}
// ******************************************************************
@@ -234,7 +231,6 @@
{
if(sound) {
LOG( ("shutdown sound system.") );
- sound->shutdown();
delete sound;
sound = 0;
}
Index: netpanzer/src/NetPanzer/Interfaces/MapInterface.hpp
diff -u netpanzer/src/NetPanzer/Interfaces/MapInterface.hpp:1.2
netpanzer/src/NetPanzer/Interfaces/MapInterface.hpp:1.3
--- netpanzer/src/NetPanzer/Interfaces/MapInterface.hpp:1.2 Mon Sep 1
16:24:20 2003
+++ netpanzer/src/NetPanzer/Interfaces/MapInterface.hpp Mon Sep 8 08:12:19 2003
@@ -28,165 +28,167 @@
#include "Surface.hpp"
class MapInterface : protected TileInterface
- {
- protected:
- static WorldMap main_map;
- static SpawnList spawn_list;
- static WadMapTable wad_mapping_table;
- static Surface mini_map_surface;
- static char map_path[256];
-
- protected:
- static void generateMappingTable( void );
- static void buildMiniMapSurface( void );
-
- public:
-
- static inline void getMapPointSize( PointXYi *map_size )
- {
- map_size->x = main_map.getXsize() * tile_set.getTileXsize();
- map_size->y = main_map.getYsize() * tile_set.getTileYsize();
- }
-
- static inline void getMapSize( PointXYi *map_size )
- {
- map_size->x = main_map.getXsize();
- map_size->y = main_map.getYsize();
- }
-
- static inline PointXYi getMapSize( void )
- {
- return( PointXYi( main_map.getXsize(), main_map.getYsize() ) );
- }
+{
+protected:
+ static WorldMap main_map;
+ static SpawnList spawn_list;
+ static WadMapTable wad_mapping_table;
+ static Surface mini_map_surface;
+ static char map_path[256];
+
+protected:
+ static void generateMappingTable( void );
+ static void buildMiniMapSurface( void );
+
+public:
+ static inline void getMapPointSize(PointXYi *map_size)
+ {
+ map_size->x = main_map.getXsize() * tile_set.getTileXsize();
+ map_size->y = main_map.getYsize() * tile_set.getTileYsize();
+ }
+
+ static inline void getMapSize(PointXYi *map_size)
+ {
+ map_size->x = main_map.getXsize();
+ map_size->y = main_map.getYsize();
+ }
+
+ static inline PointXYi getMapSize()
+ {
+ return( PointXYi( main_map.getXsize(), main_map.getYsize() ) );
+ }
- static inline unsigned long getMapXsize( void )
- {
- return( (unsigned long) (main_map.getXsize()) );
- }
-
- static inline unsigned long getMapYsize( void )
- {
- return( (unsigned long) (main_map.getYsize()) );
- }
-
- static inline MapElementType MapValue( unsigned short map_x, unsigned short
map_y )
- {
- return( main_map.mapValue(map_x, map_y) );
- }
-
- static inline MapElementType MapValue( unsigned long offset )
- {
- return( main_map.mapValue(offset) );
- }
+ static inline unsigned long getMapXsize()
+ {
+ return( (unsigned long) (main_map.getXsize()) );
+ }
+
+ static inline unsigned long getMapYsize()
+ {
+ return( (unsigned long) (main_map.getYsize()) );
+ }
+
+ static inline MapElementType MapValue(unsigned short map_x,
+
unsigned short map_y)
+ {
+ return( main_map.mapValue(map_x, map_y) );
+ }
+
+ static inline MapElementType MapValue(unsigned long offset)
+ {
+ return( main_map.mapValue(offset) );
+ }
static void offsetToPointXY( unsigned long offset,
- unsigned long *point_x, unsigned long
*point_y )
- {
- *point_y = ( offset / main_map.getXsize() );
-
- *point_x = ( offset - ( (*point_y) * main_map.getXsize() ) ) * 32
- + (32 / 2);
+ unsigned long *point_x, unsigned long *point_y )
+ {
+ *point_y = ( offset / main_map.getXsize() );
+
+ *point_x = ( offset - ( (*point_y) * main_map.getXsize() ) ) * 32
+ + (32 / 2);
- *point_y = (*point_y) * 32 + (32 / 2);
- }
+ *point_y = (*point_y) * 32 + (32 / 2);
+ }
static inline void offsetToMapXY( unsigned long offset, unsigned short
*map_x, unsigned short *map_y )
- {
- main_map.offsetToMapXY( offset, map_x, map_y );
- }
+ {
+ main_map.offsetToMapXY( offset, map_x, map_y );
+ }
static inline void offsetToMapXY( unsigned long offset, PointXYi *map_loc )
- {
- unsigned short map_x, map_y;
- main_map.offsetToMapXY( offset, &map_x, &map_y );
- map_loc->x = map_x;
- map_loc->y = map_y;
- }
-
- static void mapXYtoPointXY( unsigned short map_x, unsigned short map_y,
unsigned long *point_x, unsigned long *point_y )
- {
- *point_x = (map_x * 32) + (32 / 2);
- *point_y = (map_y * 32) + (32 / 2);
- }
+ {
+ unsigned short map_x, map_y;
+ main_map.offsetToMapXY( offset, &map_x, &map_y );
+ map_loc->x = map_x;
+ map_loc->y = map_y;
+ }
+
+ static void mapXYtoPointXY( unsigned short map_x, unsigned short map_y,
+ unsigned long *point_x, unsigned long *point_y )
+ {
+ *point_x = (map_x * 32) + (32 / 2);
+ *point_y = (map_y * 32) + (32 / 2);
+ }
static void mapXYtoPointXY( PointXYi map_loc, PointXYi *loc )
- {
- loc->x = (map_loc.x * 32) + (32 / 2);
- loc->y = (map_loc.y * 32) + (32 / 2);
- }
-
- static inline void pointXYtoMapXY( unsigned long point_x, unsigned long
point_y, unsigned short *map_x, unsigned short *map_y )
- {
- *map_x = (unsigned short ) point_x / 32;
- *map_y = (unsigned short ) point_y / 32;
- }
-
- static inline void pointXYtoMapXY( PointXYi point, PointXYi *map_loc )
- {
- map_loc->x = (unsigned short ) point.x / 32;
- map_loc->y = (unsigned short ) point.y / 32;
- }
-
- static inline void mapXYtoOffset( unsigned short map_x, unsigned short
map_y, unsigned long *offset )
- {
- main_map.mapXYtoOffset( map_x, map_y, offset );
- }
+ {
+ loc->x = (map_loc.x * 32) + (32 / 2);
+ loc->y = (map_loc.y * 32) + (32 / 2);
+ }
+
+ static inline void pointXYtoMapXY( unsigned long point_x,
+ unsigned long point_y, unsigned short *map_x, unsigned short
*map_y )
+ {
+ *map_x = (unsigned short ) point_x / 32;
+ *map_y = (unsigned short ) point_y / 32;
+ }
+
+ static inline void pointXYtoMapXY( PointXYi point, PointXYi *map_loc )
+ {
+ map_loc->x = (unsigned short ) point.x / 32;
+ map_loc->y = (unsigned short ) point.y / 32;
+ }
+
+ static inline void mapXYtoOffset( unsigned short map_x, unsigned short
map_y,
+ unsigned long *offset )
+ {
+ main_map.mapXYtoOffset( map_x, map_y, offset );
+ }
static inline void mapXYtoOffset( PointXYi &map_loc, unsigned long *offset )
- {
- main_map.mapXYtoOffset( map_loc.x, map_loc.y, offset );
- }
+ {
+ main_map.mapXYtoOffset( map_loc.x, map_loc.y, offset );
+ }
static inline void markLocHack( const PointXYi &loc )
- {
- unsigned short *map_buffer;
- unsigned long offset;
- main_map.getRawMapBuffer( &map_buffer );
- offset = ( loc.y * getMapXsize() ) + loc.x;
- map_buffer[ offset ] = 27;
- }
+ {
+ unsigned short *map_buffer;
+ unsigned long offset;
+ main_map.getRawMapBuffer( &map_buffer );
+ offset = ( loc.y * getMapXsize() ) + loc.x;
+ map_buffer[ offset ] = 27;
+ }
static inline void unmarkLocHack( const PointXYi &loc )
- {
- unsigned short *map_buffer;
- unsigned long offset;
- main_map.getRawMapBuffer( &map_buffer );
- offset = ( loc.y * getMapXsize() ) + loc.x;
- map_buffer[ offset ] = 28;
- }
+ {
+ unsigned short *map_buffer;
+ unsigned long offset;
+ main_map.getRawMapBuffer( &map_buffer );
+ offset = ( loc.y * getMapXsize() ) + loc.x;
+ map_buffer[ offset ] = 28;
+ }
static void normalizePointXY( unsigned long point_x, unsigned long point_y,
unsigned long *norm_x, unsigned long *norm_y )
- {
- unsigned short map_x, map_y;
+ {
+ unsigned short map_x, map_y;
- pointXYtoMapXY( point_x, point_y, &map_x, &map_y );
- mapXYtoPointXY( map_x, map_y, norm_x, norm_y );
- }
-
+ pointXYtoMapXY( point_x, point_y, &map_x, &map_y );
+ mapXYtoPointXY( map_x, map_y, norm_x, norm_y );
+ }
static inline void MapInterface::getRawMapBuffer( MapElementType
**raw_buffer )
- {
- main_map.getRawMapBuffer( raw_buffer );
- }
+ {
+ main_map.getRawMapBuffer( raw_buffer );
+ }
static inline WorldMap * getMap( void )
- {
- return( &main_map );
- }
-
- protected:
- static void finishMapLoad( void );
- public:
+ {
+ return( &main_map );
+ }
+
+protected:
+ static void finishMapLoad();
+public:
static bool startMapLoad( const char *file_path, bool load_tiles, unsigned
long partitions );
static bool loadMap( int *percent_complete );
- static inline bool isMapLoaded( void )
- { return( main_map.isMapLoaded() ); }
+ static inline bool isMapLoaded()
+ { return( main_map.isMapLoaded() ); }
- static inline Surface * getMiniMapSurface( void )
- {
- return ( &mini_map_surface );
- }
+ static inline Surface * getMiniMapSurface()
+ {
+ return ( &mini_map_surface );
+ }
static unsigned char getMovementValue( PointXYi map_loc );
@@ -195,16 +197,14 @@
static unsigned char getAverageColorMapXY( PointXYi &map_loc );
static inline void getFreeSpawnPoint( PointXYi *spawn_loc )
- {
- spawn_list.getFreeSpawnPoint( spawn_loc );
- }
+ {
+ spawn_list.getFreeSpawnPoint( spawn_loc );
+ }
static inline SpawnList * getSpawnList( void )
- {
- return( &spawn_list );
- }
-
-
- };
+ {
+ return( &spawn_list );
+ }
+};
#endif
Index: netpanzer/src/NetPanzer/Interfaces/WorldViewInterface.hpp
diff -u netpanzer/src/NetPanzer/Interfaces/WorldViewInterface.hpp:1.2
netpanzer/src/NetPanzer/Interfaces/WorldViewInterface.hpp:1.3
--- netpanzer/src/NetPanzer/Interfaces/WorldViewInterface.hpp:1.2 Mon Sep
1 16:24:21 2003
+++ netpanzer/src/NetPanzer/Interfaces/WorldViewInterface.hpp Mon Sep 8
08:12:19 2003
@@ -23,76 +23,73 @@
#include "ViewCamera.hpp"
class WorldViewInterface : virtual PObject
- {
- protected:
- static ViewCamera *main_camera;
- static ViewCamera camera_list[10];
+{
+protected:
+ static ViewCamera *main_camera;
+ static ViewCamera camera_list[10];
- public:
-
- WorldViewInterface();
+public:
+ WorldViewInterface();
- static inline void scroll_right( long scroll_increment )
- { main_camera->scrollPlusX(scroll_increment); }
+ static inline void scroll_right( long scroll_increment )
+ { main_camera->scrollPlusX(scroll_increment); }
- static inline void scroll_left( long scroll_increment )
- { main_camera->scrollMinusX(scroll_increment); }
+ static inline void scroll_left( long scroll_increment )
+ { main_camera->scrollMinusX(scroll_increment); }
- static inline void scroll_up( long scroll_increment )
- { main_camera->scrollMinusY(scroll_increment); }
+ static inline void scroll_up( long scroll_increment )
+ { main_camera->scrollMinusY(scroll_increment); }
- static inline void scroll_down( long scroll_increment )
- { main_camera->scrollPlusY(scroll_increment); }
+ static inline void scroll_down( long scroll_increment )
+ { main_camera->scrollPlusY(scroll_increment); }
- static inline void setCameraPosition( const PointXYi &world_loc )
- {
- main_camera->setCamera( world_loc );
- }
+ static inline void setCameraPosition( const PointXYi &world_loc )
+ {
+ main_camera->setCamera( world_loc );
+ }
- static inline void setCameraSize( unsigned long view_size_x, unsigned long
view_size_y )
+ static inline void setCameraSize( unsigned long view_size_x, unsigned
long view_size_y )
{
- main_camera->setCameraSize( PointXYi( view_size_x, view_size_y ) );
+ main_camera->setCameraSize( PointXYi( view_size_x, view_size_y
) );
}
- static inline void getViewWindow( Recti *view_win )
- {
- main_camera->getViewWindow( view_win );
+ static inline void getViewWindow( Recti *view_win )
+ {
+ main_camera->getViewWindow( view_win );
}
- static inline void clientXYtoWorldXY( Recti &view_win,
- PointXYi &client, PointXYi *world )
- {
- world->x = view_win.min.x + client.x;
- world->y = view_win.min.y + client.y;
- }
-
+ static inline void clientXYtoWorldXY( Recti &view_win,
+ PointXYi &client, PointXYi *world )
+ {
+ world->x = view_win.min.x + client.x;
+ world->y = view_win.min.y + client.y;
+ }
- static inline void worldXYtoClientXY( Recti &view_win,
- PointXYi &world, PointXYi *client )
- {
- client->x = world.x - view_win.min.x;
- client->y = world.y - view_win.min.y;
- }
+ static inline void worldXYtoClientXY( Recti &view_win,
+ PointXYi &world, PointXYi *client )
+ {
+ client->x = world.x - view_win.min.x;
+ client->y = world.y - view_win.min.y;
+ }
static inline Recti getViewWindow( void )
- {
- Recti view_win;
- main_camera->getViewWindow( &view_win );
- return( view_win );
- }
+ {
+ Recti view_win;
+ main_camera->getViewWindow( &view_win );
+ return( view_win );
+ }
static inline PointXYi getViewWindowMin( void )
- {
- Recti view_win;
- main_camera->getViewWindow( &view_win );
- return( view_win.min );
- }
+ {
+ Recti view_win;
+ main_camera->getViewWindow( &view_win );
+ return( view_win.min );
+ }
static inline long getCameraDistance( PointXYi &world_loc )
- {
- return( main_camera->getCameraDistance( world_loc ) );
- }
- };
-
+ {
+ return( main_camera->getCameraDistance( world_loc ) );
+ }
+};
#endif // ** _WORLDVIEWINTERFACE_HPP
Index: netpanzer/src/NetPanzer/Port/Gdatstct.hpp
diff -u netpanzer/src/NetPanzer/Port/Gdatstct.hpp:1.2
netpanzer/src/NetPanzer/Port/Gdatstct.hpp:1.3
--- netpanzer/src/NetPanzer/Port/Gdatstct.hpp:1.2 Mon Sep 1 16:24:21 2003
+++ netpanzer/src/NetPanzer/Port/Gdatstct.hpp Mon Sep 8 08:12:19 2003
@@ -20,24 +20,22 @@
#include "Sprite.hpp"
-typedef
- struct
- {
- char name[32]; // name of sprite -- default file from which it was
extracted
- short pyro_id; // pryosoft id #
- short x_size; // width of sprite in pixels
- short y_size; // height of sprite in pixels
+struct sprite_data
+{
+ char name[32]; // name of sprite -- default file from which it was
extracted
+ short pyro_id; // pryosoft id #
+ short x_size; // width of sprite in pixels
+ short y_size; // height of sprite in pixels
- short g_attrib; // sprite attributes
+ short g_attrib; // sprite attributes
// bit 0 = standard pic
// bit 1 = transparent
// bit 2 = shadowed
- long data_size; // size of sprite data in bytes
+ long data_size; // size of sprite data in bytes
// ususally x_size * y_size
- unsigned char *data;
-
- }sprite_data;
+ unsigned char *data;
+};
//****************************************************************************************
Index: netpanzer/src/NetPanzer/Port/Wrldsprt.hpp
diff -u netpanzer/src/NetPanzer/Port/Wrldsprt.hpp:1.2
netpanzer/src/NetPanzer/Port/Wrldsprt.hpp:1.3
--- netpanzer/src/NetPanzer/Port/Wrldsprt.hpp:1.2 Mon Sep 1 16:24:21 2003
+++ netpanzer/src/NetPanzer/Port/Wrldsprt.hpp Mon Sep 8 08:12:19 2003
@@ -58,17 +58,17 @@
};
class world_sprite : public world_sprite_base
- {
- public:
- sprite_data *sprite;
+{
+public:
+ sprite_data *sprite;
- world_sprite( void );
- virtual short is_visible( void );
- virtual void set_data( void *data );
- virtual void set_data( void *data, short attach_offset_x, short
attach_offset_y, unsigned char height_val );
- virtual void update( long x, long y );
- virtual void blit( void );
- };
+ world_sprite( void );
+ virtual short is_visible( void );
+ virtual void set_data( void *data );
+ virtual void set_data( void *data, short attach_offset_x, short
attach_offset_y, unsigned char height_val );
+ virtual void update( long x, long y );
+ virtual void blit( void );
+};
class world_animation : public world_sprite_base
{
Index: netpanzer/src/NetPanzer/Port/blitters.cpp
diff -u netpanzer/src/NetPanzer/Port/blitters.cpp:1.5
netpanzer/src/NetPanzer/Port/blitters.cpp:1.6
--- netpanzer/src/NetPanzer/Port/blitters.cpp:1.5 Sun Sep 7 22:44:22 2003
+++ netpanzer/src/NetPanzer/Port/blitters.cpp Mon Sep 8 08:12:19 2003
@@ -16,26 +16,26 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <config.h>
+
#include <assert.h>
#include "blitters.h"
-#include "codewiz.hpp"
#include <string.h>
#include "UIDraw.hpp"
-void blit_partial_xy( unsigned char *tile_ptr,unsigned char *buffer_ptr,short
y_size,short x_size)
+void blit_partial_xy(const unsigned char *tile_ptr, unsigned char *buffer_ptr,
+ short y_size, short x_size)
{
- assert(isValidPtr(tile_ptr));
- assert(isValidPtr(buffer_ptr));
+ assert(tile_ptr != 0);
+ assert(buffer_ptr != 0);
assert(y_size > 0);
assert(x_size > 0);
- int y;
-
-// XXX 32 should be at least a define, but probably a variable. Pass in class
instead of data pointer.
- for(y=0; y<y_size; y++) {
- memcpy(buffer_ptr, tile_ptr, x_size);
- buffer_ptr += Screen->getWidth()-x_size;
- tile_ptr += 32-x_size;
+ // XXX 32 should be at least a define, but probably a variable.
+ // Pass in class instead of data pointer.
+ for(int y=0; y<y_size; y++) {
+ memcpy(buffer_ptr, tile_ptr, x_size);
+ buffer_ptr += Screen->getWidth();
+ tile_ptr += 32;
}
#if 0
@@ -103,15 +103,17 @@
*/
-void blit_partial_y( unsigned char *tile_ptr, unsigned char *buffer_ptr, short
y_size)
+void blit_partial_y(const unsigned char *tile_ptr, unsigned char *buffer_ptr,
+ short y_size)
{
int y;
// XXX remove 'magic' 32
for(y=0; y<y_size; y++) {
- memcpy(tile_ptr, buffer_ptr, 32);
+ memcpy(buffer_ptr, tile_ptr, 32);
tile_ptr += 32;
- buffer_ptr += Screen->getWidth()-32;
+ buffer_ptr += Screen->getWidth() /*-32*/;
}
+
#if 0
__asm
{
@@ -180,19 +182,21 @@
}
-void general_blitter( unsigned char x_size, unsigned char y_size, unsigned
long frame_offset,
- unsigned char *buffer_ptr, unsigned char *dbuffer_ptr )
- {
- int x,y;
- dbuffer_ptr += frame_offset;
- for(y=0; y<y_size; y++) {
- for(x=0; x<x_size; x++) {
- if(buffer_ptr[x] != 0)
- dbuffer_ptr[x]=buffer_ptr[x];
- }
- buffer_ptr += Screen->getWidth()-x_size;
- dbuffer_ptr += Screen->getWidth()-x_size;
- }
+void general_blitter(unsigned char x_size, unsigned char y_size,
+ unsigned long frame_offset, const unsigned char *buffer_ptr,
+ unsigned char *dbuffer_ptr)
+{
+ int x,y;
+
+ dbuffer_ptr += frame_offset;
+ for(y=0; y<y_size; y++) {
+ for(x=0; x<x_size; x++) {
+ if(buffer_ptr[x] != 0)
+ dbuffer_ptr[x]=buffer_ptr[x];
+ }
+ buffer_ptr += Screen->getWidth()-x_size;
+ dbuffer_ptr += Screen->getWidth()-x_size;
+ }
#if 0
__asm
Index: netpanzer/src/NetPanzer/Port/blitters.h
diff -u netpanzer/src/NetPanzer/Port/blitters.h:1.1
netpanzer/src/NetPanzer/Port/blitters.h:1.2
--- netpanzer/src/NetPanzer/Port/blitters.h:1.1 Sun Dec 1 12:51:56 2002
+++ netpanzer/src/NetPanzer/Port/blitters.h Mon Sep 8 08:12:19 2003
@@ -18,13 +18,15 @@
#ifndef _BLITTERS_H
#define _BLITTERS_H
-void blit_partial_xy( unsigned char *tile_ptr,unsigned char *buffer_ptr,short
y_size,short x_size );
+void blit_partial_xy(const unsigned char *tile_ptr, unsigned char *buffer_ptr,
+ short y_size,short x_size);
+void blit_partial_y(const unsigned char *tile_ptr, unsigned char *buffer_ptr,
+ short y_size);
-void blit_partial_y( unsigned char *tile_ptr, unsigned char *buffer_ptr, short
y_size);
-
-void general_blitter( unsigned char x_size, unsigned char y_size, unsigned
long frame_offset,
- unsigned char *buffer_ptr, unsigned char *dbuffer_ptr );
+void general_blitter(unsigned char x_size, unsigned char y_size,
+ unsigned long frame_offset, const unsigned char *buffer_ptr,
+ unsigned char *dbuffer_ptr);
void blit_selector_square( unsigned char x_size, unsigned char y_size,
unsigned long frame_offset, unsigned char
*dbuffer_ptr );
Index: netpanzer/src/UILib/SDL/SDLDraw.cpp
diff -u netpanzer/src/UILib/SDL/SDLDraw.cpp:1.6
netpanzer/src/UILib/SDL/SDLDraw.cpp:1.7
--- netpanzer/src/UILib/SDL/SDLDraw.cpp:1.6 Sun Sep 7 22:44:22 2003
+++ netpanzer/src/UILib/SDL/SDLDraw.cpp Mon Sep 8 08:12:19 2003
@@ -28,10 +28,12 @@
SDLDraw::SDLDraw()
: FrontBuffer(0)
{
+ SDL_InitSubSystem(SDL_INIT_VIDEO);
}
SDLDraw::~SDLDraw()
{
+ SDL_QuitSubSystem(SDL_INIT_VIDEO);
}
bool SDLDraw::initialize()
Index: netpanzer/src/UILib/SDL/SDLSound.cpp
diff -u netpanzer/src/UILib/SDL/SDLSound.cpp:1.3
netpanzer/src/UILib/SDL/SDLSound.cpp:1.4
--- netpanzer/src/UILib/SDL/SDLSound.cpp:1.3 Sat Sep 6 18:31:20 2003
+++ netpanzer/src/UILib/SDL/SDLSound.cpp Mon Sep 8 08:12:19 2003
@@ -17,23 +17,32 @@
*/
#include <config.h>
+#include <sys/types.h>
+#include <dirent.h>
+#include <errno.h>
+#include <algorithm>
+
+#include <SDL.h>
+#include <SDL_mixer.h>
+#include "Log.hpp"
+#include "Exception.hpp"
#include "SDLSound.hpp"
SDLSound::SDLSound()
{
+ if(SDL_InitSubSystem(SDL_INIT_AUDIO) < 0)
+ throw Exception("SDL_Init audio error: %s", SDL_GetError());
+
+ if(Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 1024) < 0)
+ throw Exception("Couldn't open audio device: %s",
Mix_GetError());
}
SDLSound::~SDLSound()
{
-}
+ stopMusic();
+ Mix_CloseAudio();
-bool SDLSound::initialize()
-{
- return true;
-}
-
-void SDLSound::shutdown()
-{
+ SDL_QuitSubSystem(SDL_INIT_AUDIO);
}
void SDLSound::PlayTankIdle()
@@ -66,5 +75,84 @@
void SDLSound::PlayAmbientSound(int, Event, long)
{
+}
+
+//---------------------------------------------------------------------------
+// Music part
+//---------------------------------------------------------------------------
+
+std::vector<std::string> SDLSound::musicfiles;
+std::vector<std::string>::iterator SDLSound::currentsong;
+
+void SDLSound::playMusic(const char* directory)
+{
+ // Part1: scan directory for music files
+ DIR* dir = opendir(directory);
+ if(!dir) {
+ LOG (("Couldn't scan directory '%s': %s",
+ directory, strerror(errno)));
+ return;
+ }
+
+ musicfiles.clear();
+ struct dirent* entry;
+ while( (entry = readdir(dir)) ) {
+ if(entry->d_name[0] == '.')
+ continue;
+
+ std::string filename = directory;
+ filename += entry->d_name;
+ musicfiles.push_back(filename);
+ }
+ closedir(dir);
+
+ if(musicfiles.size() == 0)
+ return;
+
+ // Part2: play music :)
+ currentsong = musicfiles.end();
+ nextSong();
+ Mix_HookMusicFinished(nextSong);
+}
+
+void SDLSound::stopMusic()
+{
+ // nicely fade the music out for 1 second
+ if(Mix_PlayingMusic()) {
+ Mix_HookMusicFinished(0);
+ Mix_FadeOutMusic(1000);
+ SDL_Delay(1000);
+ }
+}
+
+void SDLSound::nextSong()
+{
+ if(currentsong == musicfiles.end()) {
+ // create a new random playlist
+ std::random_shuffle(musicfiles.begin(), musicfiles.end());
+ currentsong = musicfiles.begin();
+ }
+
+ std::vector<std::string>::iterator lastsong = currentsong;
+ do {
+ const char* toplay = currentsong->c_str();
+ Mix_Music* music = Mix_LoadMUS(toplay);
+ currentsong++;
+
+ if(music) {
+ if (Mix_PlayMusic(music, 1) == 0) {
+ LOG( ("Start playing song '%s'", toplay) );
+ break;
+ } else {
+ LOG ( ("Failed to play song '%s': %s", toplay,
Mix_GetError()));
+ }
+ } else {
+ LOG ( ("Failed to load song '%s': %s", toplay,
Mix_GetError()));
+ }
+
+ if(currentsong == musicfiles.end()) {
+ currentsong = musicfiles.begin();
+ }
+ } while(currentsong != lastsong);
}
Index: netpanzer/src/UILib/SDL/SDLSound.hpp
diff -u netpanzer/src/UILib/SDL/SDLSound.hpp:1.2
netpanzer/src/UILib/SDL/SDLSound.hpp:1.3
--- netpanzer/src/UILib/SDL/SDLSound.hpp:1.2 Sat Sep 6 18:31:20 2003
+++ netpanzer/src/UILib/SDL/SDLSound.hpp Mon Sep 8 08:12:19 2003
@@ -18,6 +18,8 @@
#ifndef __UILIB_SDLSOUND_HPP__
#define __UILIB_SDLSOUND_HPP__
+#include <string>
+#include <vector>
#include "UILib/Sound.hpp"
class SDLSound : public Sound
@@ -26,9 +28,6 @@
SDLSound();
virtual ~SDLSound();
- virtual bool initialize();
- virtual void shutdown();
-
virtual void PlayTankIdle();
virtual void StopTankIdle();
virtual void PlayMenuSound();
@@ -37,6 +36,16 @@
virtual void PlayUnitSound(int unit_type);
virtual void PlayUnitVoice(int unit_type, Event event);
virtual void PlayAmbientSound(int unit_type, Event event, long
distance);
+ virtual void playSound(const char* name)
+ {}
+
+ virtual void playMusic(const char* directory);
+ virtual void stopMusic();
+
+private:
+ static void nextSong();
+ static std::vector<std::string> musicfiles;
+ static std::vector<std::string>::iterator currentsong;
};
#endif
Index: netpanzer/src/UILib/Sound.hpp
diff -u netpanzer/src/UILib/Sound.hpp:1.2 netpanzer/src/UILib/Sound.hpp:1.3
--- netpanzer/src/UILib/Sound.hpp:1.2 Sat Sep 6 18:31:20 2003
+++ netpanzer/src/UILib/Sound.hpp Mon Sep 8 08:12:19 2003
@@ -27,10 +27,10 @@
_under_attack, _fire_gun, _hit_target, _miss_target, _scream,
_random_battle, _blow_up_tank
};
-
- virtual bool initialize() = 0;
- virtual void shutdown() = 0;
+ virtual ~Sound()
+ { }
+
virtual void PlayTankIdle() = 0;
virtual void StopTankIdle() = 0;
virtual void PlayMenuSound() = 0;
@@ -39,6 +39,11 @@
virtual void PlayUnitSound(int unit_type) = 0;
virtual void PlayUnitVoice(int unit_type, Event event) = 0;
virtual void PlayAmbientSound(int unit_type, Event event, long
distance)=0;
+
+ virtual void playSound(const char* name) = 0;
+
+ virtual void playMusic(const char* directory) = 0;
+ virtual void stopMusic() = 0;
};
extern Sound* sound;
Index: netpanzer/src/UILib/UIDraw.hpp
diff -u netpanzer/src/UILib/UIDraw.hpp:1.5 netpanzer/src/UILib/UIDraw.hpp:1.6
--- netpanzer/src/UILib/UIDraw.hpp:1.5 Sun Sep 7 22:44:22 2003
+++ netpanzer/src/UILib/UIDraw.hpp Mon Sep 8 08:12:19 2003
@@ -32,32 +32,40 @@
class UIDraw
{
protected:
- int curWidth, curHeight, curBPP;
+ int curWidth, curHeight, curBPP;
public:
- virtual bool initialize() = 0;
- virtual void shutdown() = 0;
- virtual bool setVideoMode(DWORD width, DWORD height, DWORD bpp, BYTE
mode_flags) = 0;
- virtual bool isDisplayModeAvailable(int width, int height, int bpp) = 0;
- virtual bool lockDoubleBuffer(BYTE **DoubleBuffer) = 0;
- virtual bool unlockDoubleBuffer() = 0;
- virtual bool createFrameBuffer(DWORD width, DWORD height, DWORD bpp) = 0;
- virtual void setGDIStatus(bool enable) = 0;
- virtual void restoreAll()=0;
- virtual bool copyDoubleBufferandFlip()=0;
- virtual void setPalette(RGBColor *color)=0;
+ virtual ~UIDraw()
+ { }
+
+ virtual bool initialize() = 0;
+ virtual void shutdown() = 0;
+ virtual bool setVideoMode(DWORD width, DWORD height, DWORD bpp, BYTE
mode_flags) = 0;
+ virtual bool isDisplayModeAvailable(int width, int height, int bpp) = 0;
+ virtual bool lockDoubleBuffer(unsigned char **DoubleBuffer) = 0;
+ virtual bool unlockDoubleBuffer() = 0;
+ virtual bool createFrameBuffer(DWORD width, DWORD height, DWORD bpp) =
0;
+ virtual void setGDIStatus(bool enable) = 0;
+ virtual void restoreAll()=0;
+ virtual bool copyDoubleBufferandFlip()=0;
+ virtual void setPalette(RGBColor *color)=0;
- int getWidth(void) { return curWidth; }
- int getHeight(void) { return curHeight; }
- int getBPP(void) { return curBPP; }
+ inline int getWidth() const
+ { return curWidth; }
+ inline int getHeight() const
+ { return curHeight; }
+ inline int getBPP()
+ { return curBPP; }
}; // end DirectDraw
// XXX some global vars, these should be avoided or at least moved inside the
// UIDraw class!!!
+#if 0
extern unsigned long DBUFFER_WIDTH;
extern unsigned long DBUFFER_HEIGHT;
extern unsigned long DBUFFER_VIEW_WIDTH;
extern unsigned long DBUFFER_VIEW_HEIGHT;
+#endif
extern unsigned long X_CLIP_OFS;
extern unsigned long Y_CLIP_OFS;
extern unsigned long OFFSET_TO_VIEW;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [netPanzer-CVS] netpanzer/src Makefile Lib/2D/Span.cpp Lib/Part...,
Matthias Braun <=