some stuff...
Taylor Richards
mtrs at bellsouth.net
Thu Jul 31 23:51:41 EDT 2003
As I've beaten Neverwinter Nights twice now I guess it's about time to
get back to Freespace... until Tux Games comes through with the add-on
anyway.
Here is a jumble of things but I'll break it down into smaller pieces if
that's easier to look at. Most of this is just some old cleanup,
getting rid of compiler messages and what not. A couple of fixes for
errors that Valgrind reported. I commented out any unused variables
rather than removing them since they are used in old, commented out code
in some cases (old FS1 stuff that I don't need to make it work). There
is also a change to the poll events to pass the mouse values straight to
mouse.cpp instead of passing each mouse button separately. Other than
reducing the amount of code I don't have any reason to justify this. It
would be a tiny bit simpler to make use of more mouse buttons in the
future if desired but that's really an excuse rather than a reason.
Also I removed exceptionhandler.cpp from the Makefile as none of that is
used in the UNIX build and if something similar is going to be done it's
probably going to be in a separate file. In credits.cpp I dealt with
the "precision 0" problem (%0.2d->%.2d) but being a moron I'm not sure
of any repercussions of that change when trying to build on windows
again.
Some of the new sound stuff is in there, 2D pan, play position, and
things that don't/won't work if using the Mac version of OpenAL. A
change to use GL_RGB5_A1 for the internal format of glTexImage2D is in
there. I discussed this a tiny bit with Steven and while there doesn't
seem to be any noticeable benefit on nVIDIA and ATI cards the speed gain
on a 3DFX card is 10-15x which can't be ignored. If someone objects to
this please speak up, but you'll have to answer to the Voodoo owners ;-)
Unless there are complaints, I'll start getting this stuff in over the
weekend.
One question while I'm going through old code, SOCKET is defined as an
int but on windows it's unsigned. I know that play between Linux and
Windows works but could this cause a problem somewhere down the line? I
noticed this while cleaning up the compiler messages in the networking
code. Making it unsigned is obviously a problem since INVALID_SOCKET is
-1 and that's more work to get around. So basically I have a couple of
compiler warning fixes that aren't in this patch since I don't know the
best way to deal with it.
In other news: movie code is done except for audio and is fast enough on
everything but the G400, working on streaming audio now (briefing
voices), mostly done with 3D audio, major changes to the force feedback
code to make it easier to work with in the future and for OSX support
but haven't touched it in about a month. I'll try and find enough time
to get most of this done in the next month or two... or three.
Taylor
--
Taylor Richards <mtrs at bellsouth.net>
-------------- next part --------------
? 0.patch
Index: Makefile
===================================================================
RCS file: /cvs/cvsroot/freespace2/Makefile,v
retrieving revision 1.39
diff -u -r1.39 Makefile
--- Makefile 2003/05/25 02:30:42 1.39
+++ Makefile 2003/08/01 03:07:42
@@ -247,7 +247,6 @@
./src/inetfile/cftp.cpp \
./src/inetfile/chttpget.cpp \
./src/inetfile/inetgetfile.cpp \
- ./src/exceptionhandler/exceptionhandler.cpp \
./src/network/multi.cpp \
./src/network/multi_campaign.cpp \
./src/network/multi_data.cpp \
Index: include/osapi.h
===================================================================
RCS file: /cvs/cvsroot/freespace2/include/osapi.h,v
retrieving revision 1.4
diff -u -r1.4 osapi.h
--- include/osapi.h 2003/02/20 17:41:07 1.4
+++ include/osapi.h 2003/08/01 03:07:42
@@ -39,7 +39,6 @@
#ifdef PLAT_UNIX
extern const char *detect_home(void);
-void default_registry();
#endif
// If app_name is NULL or ommited, then TITLE is used
Index: include/unix.h
===================================================================
RCS file: /cvs/cvsroot/freespace2/include/unix.h,v
retrieving revision 1.17
diff -u -r1.17 unix.h
--- include/unix.h 2002/06/09 03:16:04 1.17
+++ include/unix.h 2003/08/01 03:07:42
@@ -82,9 +82,6 @@
WORD cbSize;
} WAVEFORMATEX;
-extern void strlwr (char *str);
-extern int filelength (int fd);
-extern int MulDiv (int, int, int);
#define CRITICAL_SECTION SDL_mutex*
#ifndef NDEBUG
Index: src/freespace2/freespace.cpp
===================================================================
RCS file: /cvs/cvsroot/freespace2/src/freespace2/freespace.cpp,v
retrieving revision 1.32
diff -u -r1.32 freespace.cpp
--- src/freespace2/freespace.cpp 2003/06/19 11:51:41 1.32
+++ src/freespace2/freespace.cpp 2003/08/01 03:07:45
@@ -2391,11 +2391,6 @@
// verify that he has a valid weapons.tbl
verify_weapons_tbl();
-#ifdef PLAT_UNIX
- // setup the default osreg values if they don't exist
- default_registry();
-#endif
-
// Output version numbers to registry for auto patching purposes
os_config_write_uint(NOX("Version"), NOX("Major"), FS_VERSION_MAJOR);
os_config_write_uint(NOX("Version"), NOX("Minor"), FS_VERSION_MINOR);
@@ -2522,12 +2517,12 @@
if(has_sparky_hi && strstr(ptr, NOX("(1024x768)"))){
#else
if(strstr(ptr, NOX("(1024x768)"))){
-#endif
+#endif // NDEBUG
gr_init(GR_1024, GR_GLIDE);
} else {
gr_init(GR_640, GR_GLIDE);
}
-#endif
+#endif // E3_BUILD
} else if (!Is_standalone && ptr && (strstr(ptr, NOX("Direct 3D -") ))) {
#ifdef E3_BUILD
// always 640 for E3
@@ -2539,7 +2534,7 @@
if(has_sparky_hi && strstr(ptr, NOX("(1024x768)"))){
#else
if(strstr(ptr, NOX("(1024x768)"))){
-#endif
+#endif // NDEBUG
// Direct 3D
trying_d3d = 1;
gr_init(GR_1024, GR_DIRECT3D, depth);
@@ -2548,22 +2543,22 @@
trying_d3d = 1;
gr_init(GR_640, GR_DIRECT3D, depth);
}
-#endif
+#endif // E3_BUILD
} else {
// Software
- #ifndef NDEBUG
+#ifndef NDEBUG
if ( Use_fullscreen_at_startup && !Is_standalone) {
gr_init(GR_640, GR_DIRECTDRAW);
} else {
gr_init(GR_640, GR_SOFTWARE);
}
- #else
+#else
if ( !Is_standalone ) {
gr_init(GR_640, GR_DIRECTDRAW);
} else {
gr_init(GR_640, GR_SOFTWARE);
}
- #endif
+#endif // !NDEBUG
}
#else
if (!Is_standalone /* && ptr && (strstr(ptr, NOX("OpenGL"))) */) {
@@ -2576,7 +2571,7 @@
STUB_FUNCTION;
gr_init(GR_640, GR_SOFTWARE);
}
-#endif
+#endif // !PLAT_UNIX
// tried d3d ?
extern int Gr_inited;
@@ -7163,19 +7158,19 @@
plist[i] = NULL;
}
}
-#endif
+#endif // RELEASE_REAL
}
if ( !Is_standalone ) {
// release -- movies always play
- #if defined(NDEBUG)
+#if defined(NDEBUG)
// in RELEASE_REAL builds make the user stick in CD2 if there are no pilots on disk so that we guarantee he plays the movie
movie_play( NOX("intro.mve"), 0 );
// debug version, movie will only play with -showmovies
- #elif !defined(NDEBUG)
+#elif !defined(NDEBUG)
movie_play( NOX("intro.mve"), 0);
/*
@@ -7184,10 +7179,10 @@
movie_play( NOX("intro.mve"), 0 );
#endif
*/
- #endif
+#endif // NDEBUG
}
-#endif
+#endif // DEMO
if (Is_standalone){
gameseq_post_event(GS_EVENT_STANDALONE_MAIN);
@@ -8589,7 +8584,7 @@
rval = 1;
- #ifndef DEMO
+#ifndef DEMO
i = find_freespace_cd();
rval = set_cdrom_path(i);
@@ -8601,7 +8596,7 @@
nprintf(("CD", "FreeSpace CD not found\n"));
}
*/
- #endif
+#endif
return rval;
}
Index: src/freespace2/unixmain.cpp
===================================================================
RCS file: /cvs/cvsroot/freespace2/src/freespace2/unixmain.cpp,v
retrieving revision 1.8
diff -u -r1.8 unixmain.cpp
--- src/freespace2/unixmain.cpp 2003/02/20 17:41:07 1.8
+++ src/freespace2/unixmain.cpp 2003/08/01 03:07:45
@@ -12,7 +12,7 @@
char userdir[MAX_PATH];
// create user game directory
- snprintf(userdir, sizeof(userdir), "%s/%s", detect_home(), Osreg_user_dir);
+ snprintf(userdir, MAX_PATH, "%s/%s", detect_home(), Osreg_user_dir);
_mkdir(userdir, 0700);
char *argptr = NULL;
Index: src/graphics/font.cpp
===================================================================
RCS file: /cvs/cvsroot/freespace2/src/graphics/font.cpp,v
retrieving revision 1.8
diff -u -r1.8 font.cpp
--- src/graphics/font.cpp 2003/06/19 11:51:41 1.8
+++ src/graphics/font.cpp 2003/08/01 03:07:45
@@ -316,7 +316,12 @@
letter2 = c2-Current_font->first_ascii;
+#ifndef MAKE_FS1
if ((letter2>=0) && (letter2<Current_font->num_chars) ) { //not in font, draw as space
+#else
+ // umm, not sure about this, issue with FS1 fonts that's no longer handled apparently
+ if ((letter2>=0) && (letter2<Current_font->num_chars) && (Current_font->num_kern_pairs != 159) ) { //not in font, draw as space
+#endif
font_kernpair *k = &Current_font->kern_data[i];
while( (k->c1 == letter) && (k->c2<letter2) && (i<Current_font->num_kern_pairs) ) {
i++;
Index: src/graphics/gropengl.cpp
===================================================================
RCS file: /cvs/cvsroot/freespace2/src/graphics/gropengl.cpp,v
retrieving revision 1.66
diff -u -r1.66 gropengl.cpp
--- src/graphics/gropengl.cpp 2003/06/22 12:52:34 1.66
+++ src/graphics/gropengl.cpp 2003/08/01 03:07:47
@@ -1905,14 +1905,13 @@
static void opengl_tcache_frame ()
{
- int idx, s_idx;
-
GL_last_bitmap_id = -1;
GL_textures_in_frame = 0;
GL_frame_count++;
/*
+ int idx, s_idx;
int i;
for( i=0; i<MAX_BITMAPS; i++ ) {
Textures[i].used_this_frame = 0;
@@ -2185,7 +2184,7 @@
size = tex_w*tex_h*2;
- glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, tex_w, tex_h, 0, GL_BGRA,
+ glTexImage2D (GL_TEXTURE_2D, 0, GL_RGB5_A1, tex_w, tex_h, 0, GL_BGRA,
GL_UNSIGNED_SHORT_1_5_5_5_REV, texmem);
free(texmem);
@@ -2219,7 +2218,7 @@
size = tex_w*tex_h*2;
- glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, tex_w, tex_h, 0, GL_BGRA,
+ glTexImage2D (GL_TEXTURE_2D, 0, GL_RGB5_A1, tex_w, tex_h, 0, GL_BGRA,
GL_UNSIGNED_SHORT_1_5_5_5_REV, texmem);
free(texmem);
@@ -2814,10 +2813,8 @@
if (!Cmdline_window && ( (os_config_read_uint( NULL, "Fullscreen", 1 ) == 1) || Cmdline_fullscreen ))
flags |= SDL_FULLSCREEN;
- // don't automatically grab key/mouse if cmdline says so, else do
- if(Cmdline_no_grab) {
- SDL_WM_GrabInput(SDL_GRAB_OFF);
- } else {
+ // grab mouse/key unless told otherwise, ignore when we are going fullscreen
+ if ( !((flags & SDL_FULLSCREEN) || Cmdline_no_grab) ) {
SDL_WM_GrabInput(SDL_GRAB_ON);
}
@@ -2828,11 +2825,12 @@
}
SDL_ShowCursor(0);
- SDL_WM_SetCaption (Osreg_title, "FS2");
+ SDL_WM_SetCaption (Osreg_title, NULL);
/* might as well put this here */
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
#endif
+
GL_use_luminance_alpha = os_config_read_uint(NOX("OpenGL"), NOX("UseLuminanceAlpha"), 0);
glViewport(0, 0, gr_screen.max_w, gr_screen.max_h);
@@ -2981,10 +2979,10 @@
gr_opengl_clear();
Gr_current_red = &Gr_red;
- Gr_current_blue = &Gr_blue;
+ Gr_current_blue = &Gr_blue;
Gr_current_green = &Gr_green;
Gr_current_alpha = &Gr_alpha;
-
+
gr_screen.gf_flip = gr_opengl_flip;
gr_screen.gf_flip_window = gr_opengl_flip_window;
gr_screen.gf_set_clip = gr_opengl_set_clip;
Index: src/hud/hud.cpp
===================================================================
RCS file: /cvs/cvsroot/freespace2/src/hud/hud.cpp,v
retrieving revision 1.6
diff -u -r1.6 hud.cpp
--- src/hud/hud.cpp 2003/06/03 04:00:40 1.6
+++ src/hud/hud.cpp 2003/08/01 03:07:48
@@ -1417,8 +1417,7 @@
gr_set_color_fast(&Color_bright_red);
if(Lcl_pl) {
gr_printf(Supernova_coords[gr_screen.res][0], Supernova_coords[gr_screen.res][1], "Wybuch supernowej : %.2f s", time_left);
- }
- else {
+ } else {
gr_printf(Supernova_coords[gr_screen.res][0], Supernova_coords[gr_screen.res][1], "Supernova Warning : %.2f s", time_left);
}
}
Index: src/menuui/credits.cpp
===================================================================
RCS file: /cvs/cvsroot/freespace2/src/menuui/credits.cpp,v
retrieving revision 1.6
diff -u -r1.6 credits.cpp
--- src/menuui/credits.cpp 2003/06/11 18:30:32 1.6
+++ src/menuui/credits.cpp 2003/08/01 03:07:48
@@ -716,9 +716,9 @@
char buf[40];
if (gr_screen.res == GR_1024) {
- sprintf(buf, NOX("2_CrIm%0.2d"), Credits_artwork_index);
+ sprintf(buf, NOX("2_CrIm%.2d"), Credits_artwork_index);
} else {
- sprintf(buf, NOX("CrIm%0.2d"), Credits_artwork_index);
+ sprintf(buf, NOX("CrIm%.2d"), Credits_artwork_index);
}
Credits_bmps[Credits_artwork_index] = bm_load(buf);
}
@@ -727,9 +727,9 @@
char buf[40];
if (gr_screen.res == GR_1024) {
- sprintf(buf, NOX("2_CrIm%0.2d"), Credits_artwork_index);
+ sprintf(buf, NOX("2_CrIm%.2d"), Credits_artwork_index);
} else {
- sprintf(buf, NOX("CrIm%0.2d"), next);
+ sprintf(buf, NOX("CrIm%.2d"), next);
}
Credits_bmps[next] = bm_load(buf);
}
Index: src/menuui/techmenu.cpp
===================================================================
RCS file: /cvs/cvsroot/freespace2/src/menuui/techmenu.cpp,v
retrieving revision 1.6
diff -u -r1.6 techmenu.cpp
--- src/menuui/techmenu.cpp 2003/05/25 02:30:42 1.6
+++ src/menuui/techmenu.cpp 2003/08/01 03:07:48
@@ -534,7 +534,7 @@
static int ShipWin04;
#endif
static ubyte Palette[768];
-static char Palette_name[128];
+//static char Palette_name[128]; // no longer used
static int Ships_loaded = 0;
static int Weapons_loaded = 0;
Index: src/missionui/missioncmdbrief.cpp
===================================================================
RCS file: /cvs/cvsroot/freespace2/src/missionui/missioncmdbrief.cpp,v
retrieving revision 1.4
diff -u -r1.4 missioncmdbrief.cpp
--- src/missionui/missioncmdbrief.cpp 2003/05/25 02:30:43 1.4
+++ src/missionui/missioncmdbrief.cpp 2003/08/01 03:07:48
@@ -390,9 +390,9 @@
static int Last_anim_frame_num;
static int Cmd_brief_last_voice;
-static int Palette_bmp = -1;
+//static int Palette_bmp = -1; // no longer used
static ubyte Palette[768];
-static char Palette_name[128];
+//static char Palette_name[128]; // no longer used
void cmd_brief_init_voice()
{
Index: src/missionui/missiondebrief.cpp
===================================================================
RCS file: /cvs/cvsroot/freespace2/src/missionui/missiondebrief.cpp,v
retrieving revision 1.8
diff -u -r1.8 missiondebrief.cpp
--- src/missionui/missiondebrief.cpp 2003/06/03 04:00:40 1.8
+++ src/missionui/missiondebrief.cpp 2003/08/01 03:07:49
@@ -2708,8 +2708,7 @@
// maybe translate for displaying
if (Lcl_gr) {
medals_translate_name(Debrief_award_text[Debrief_award_text_num_lines], AWARD_TEXT_MAX_LINE_LENGTH);
- }
- else if(Lcl_pl) {
+ } else if (Lcl_pl) {
medals_translate_name_pl(Debrief_award_text[Debrief_award_text_num_lines], AWARD_TEXT_MAX_LINE_LENGTH);
}
Index: src/missionui/missionscreencommon.cpp
===================================================================
RCS file: /cvs/cvsroot/freespace2/src/missionui/missionscreencommon.cpp,v
retrieving revision 1.6
diff -u -r1.6 missionscreencommon.cpp
--- src/missionui/missionscreencommon.cpp 2003/06/11 18:30:33 1.6
+++ src/missionui/missionscreencommon.cpp 2003/08/01 03:07:49
@@ -450,7 +450,9 @@
int Common_team;
// Ids for the instance of the anim that is playing
+#ifdef MAKE_FS1
static anim_instance *Background_anim_instance;
+#endif
int Wing_slot_empty_bitmap;
int Wing_slot_disabled_bitmap;
Index: src/missionui/redalert.cpp
===================================================================
RCS file: /cvs/cvsroot/freespace2/src/missionui/redalert.cpp,v
retrieving revision 1.5
diff -u -r1.5 redalert.cpp
--- src/missionui/redalert.cpp 2003/05/25 02:30:43 1.5
+++ src/missionui/redalert.cpp 2003/08/01 03:07:50
@@ -225,6 +225,7 @@
200
};
+#ifdef MAKE_FS1
static int Ra_flash_coords[GR_NUM_RESOLUTIONS][2] = {
{
61, 108 // GR_640
@@ -233,6 +234,7 @@
61, 108 // GR_1024
}
};
+#endif
#define NUM_BUTTONS 2
Index: src/network/multi_ingame.cpp
===================================================================
RCS file: /cvs/cvsroot/freespace2/src/network/multi_ingame.cpp,v
retrieving revision 1.3
diff -u -r1.3 multi_ingame.cpp
--- src/network/multi_ingame.cpp 2002/06/09 04:41:23 1.3
+++ src/network/multi_ingame.cpp 2003/08/01 03:07:50
@@ -381,7 +381,7 @@
LOCAL int Ingame_ships_deleted = 0;
-LOCAL int Ingame_ships_to_delete[MAX_SHIPS];
+//LOCAL int Ingame_ships_to_delete[MAX_SHIPS]; // no longer used
// --------------------------------------------------------------------------------------------------
Index: src/network/multi_voice.cpp
===================================================================
RCS file: /cvs/cvsroot/freespace2/src/network/multi_voice.cpp,v
retrieving revision 1.3
diff -u -r1.3 multi_voice.cpp
--- src/network/multi_voice.cpp 2002/06/09 04:41:24 1.3
+++ src/network/multi_voice.cpp 2003/08/01 03:07:51
@@ -1024,7 +1024,7 @@
Assert(Net_player->flags & NETINFO_FLAG_AM_MASTER);
// if the index is -1, the token has probably been released to us "officially" already
- if((Multi_voice_stream[stream_index].token_status == MULTI_VOICE_TOKEN_INDEX_FREE) || (Multi_voice_stream[stream_index].token_status == MULTI_VOICE_TOKEN_INDEX_RELEASED)){
+ if((Multi_voice_stream[stream_index].token_status == (int)MULTI_VOICE_TOKEN_INDEX_FREE) || (Multi_voice_stream[stream_index].token_status == (int)MULTI_VOICE_TOKEN_INDEX_RELEASED)){
Multi_voice_stream[stream_index].token_stamp = -1;
return;
}
Index: src/network/multimsgs.cpp
===================================================================
RCS file: /cvs/cvsroot/freespace2/src/network/multimsgs.cpp,v
retrieving revision 1.5
diff -u -r1.5 multimsgs.cpp
--- src/network/multimsgs.cpp 2002/06/17 06:33:10 1.5
+++ src/network/multimsgs.cpp 2003/08/01 03:07:53
@@ -3523,7 +3523,7 @@
// STANDALONE_ONLY
ADD_DATA( Multi_create_mission_list[i].valid_status );
- if ( packet_size > MAX_MISSION_ITEMS_BYTES ) {
+ if ( packet_size > (int)MAX_MISSION_ITEMS_BYTES ) {
stop = 1;
ADD_DATA( stop );
multi_io_send_reliable(pl, data, packet_size);
@@ -3548,7 +3548,7 @@
ADD_DATA( Multi_create_campaign_list[i].flags );
ADD_DATA( Multi_create_campaign_list[i].max_players );
- if ( packet_size > MAX_MISSION_ITEMS_BYTES ) {
+ if ( packet_size > (int)MAX_MISSION_ITEMS_BYTES ) {
stop = 1;
ADD_DATA( stop );
multi_io_send_reliable(pl, data, packet_size);
Index: src/network/psnet2.cpp
===================================================================
RCS file: /cvs/cvsroot/freespace2/src/network/psnet2.cpp,v
retrieving revision 1.9
diff -u -r1.9 psnet2.cpp
--- src/network/psnet2.cpp 2002/07/27 19:52:54 1.9
+++ src/network/psnet2.cpp 2003/08/01 03:07:54
@@ -2141,6 +2141,7 @@
local_address.sin_addr.s_addr = INADDR_ANY;
}
+ // NOTE: for memeory checkers, do NOT try to free this
ml_printf("psnet_get_ip() reports IP : %s\n", inet_ntoa(local_address.sin_addr));
return local_address.sin_addr.s_addr;
Index: src/osapi/os_unix.cpp
===================================================================
RCS file: /cvs/cvsroot/freespace2/src/osapi/os_unix.cpp,v
retrieving revision 1.14
diff -u -r1.14 os_unix.cpp
--- src/osapi/os_unix.cpp 2003/05/09 05:04:15 1.14
+++ src/osapi/os_unix.cpp 2003/08/01 03:07:54
@@ -144,10 +144,10 @@
// os-wide globals
static int fAppActive = 1;
-static int main_window_inited = 0;
-static char szWinTitle[128];
-static char szWinClass[128];
-static int WinX, WinY, WinW, WinH;
+//static int main_window_inited = 0; // not used (here)
+//static char szWinTitle[128]; // not used (here)
+//static char szWinClass[128]; // not used (here)
+//static int WinX, WinY, WinW, WinH; // not used (grsoft.cpp) in UNIX build
static int Os_inited = 0;
static CRITICAL_SECTION Os_lock;
@@ -185,8 +185,10 @@
return (getenv("HOME"));
}
-void default_registry()
-{
+// If app_name is NULL or ommited, then TITLE is used
+// for the app name, which is where registry keys are stored.
+void os_init(char * wclass, char * title, char *app_name, char *version_string )
+{
/* set some sane defaults since we don't have a laucher... */
if (os_config_read_string(NULL, NOX("Videocard"), NULL) == NULL)
os_config_write_string(NULL, NOX("Videocard"), NOX("OpenGL (640x480)"));
@@ -196,16 +198,11 @@
if (os_config_read_string(NULL, NOX("ConnectionSpeed"), NULL) == NULL)
os_config_write_string(NULL, NOX("ConnectionSpeed"), NOX("Slow"));
-}
-// If app_name is NULL or ommited, then TITLE is used
-// for the app name, which is where registry keys are stored.
-void os_init(char * wclass, char * title, char *app_name, char *version_string )
-{
- STUB_FUNCTION;
-
Os_inited = 1;
+ Os_lock = SDL_CreateMutex();
+
// check to see if we're running under msdev
os_check_debugger();
@@ -215,7 +212,7 @@
// set the main window title
void os_set_title( char * title )
{
- STUB_FUNCTION;
+ // the title is already set by SDL in gropengl.cpp
}
// call at program end
@@ -223,15 +220,15 @@
{
STUB_FUNCTION;
- #ifndef NDEBUG
+#ifndef NDEBUG
outwnd_close();
- #endif
+#endif
}
// window management -----------------------------------------------------------------
-// Returns 1 if app is not the foreground app.
+// Returns 0 if app is not the foreground app.
int os_foreground()
{
return fAppActive;
@@ -240,7 +237,7 @@
// Returns the handle to the main window
uint os_get_window()
{
- STUB_FUNCTION;
+// STUB_FUNCTION; // not used/needed with UNIX builds?
return 0;
}
@@ -278,6 +275,8 @@
// called at shutdown. Makes sure all thread processing terminates.
void os_deinit()
{
+ SDL_DestroyMutex(Os_lock);
+
SDL_Quit();
}
@@ -289,20 +288,9 @@
while (SDL_PollEvent (&e)) {
switch (e.type) {
case SDL_MOUSEBUTTONDOWN:
- if (e.button.button == SDL_BUTTON_LEFT)
- mouse_mark_button (MOUSE_LEFT_BUTTON,1);
- else if (e.button.button == SDL_BUTTON_RIGHT)
- mouse_mark_button (MOUSE_RIGHT_BUTTON,1);
- else if (e.button.button == SDL_BUTTON_MIDDLE)
- mouse_mark_button (MOUSE_MIDDLE_BUTTON, 1);
- break;
case SDL_MOUSEBUTTONUP:
- if (e.button.button == SDL_BUTTON_LEFT)
- mouse_mark_button (MOUSE_LEFT_BUTTON,0);
- else if (e.button.button == SDL_BUTTON_RIGHT)
- mouse_mark_button (MOUSE_RIGHT_BUTTON,0);
- else if (e.button.button == SDL_BUTTON_MIDDLE)
- mouse_mark_button (MOUSE_MIDDLE_BUTTON, 0);
+ if (e.button.button <= HIGHEST_MOUSE_BUTTON)
+ mouse_mark_button(e.button.button, e.button.state);
break;
case SDL_KEYDOWN:
if ((e.key.keysym.mod & KMOD_ALT) &&
@@ -334,11 +322,11 @@
}
if (SDLtoFS2[e.key.keysym.sym])
- key_mark (SDLtoFS2[e.key.keysym.sym], 1, 0);
+ key_mark (SDLtoFS2[e.key.keysym.sym], 1, 0);
break;
case SDL_KEYUP:
if (SDLtoFS2[e.key.keysym.sym])
- key_mark (SDLtoFS2[e.key.keysym.sym], 0, 0);
+ key_mark (SDLtoFS2[e.key.keysym.sym], 0, 0);
break;
case SDL_ACTIVEEVENT:
if (e.active.state & SDL_APPACTIVE) {
@@ -362,7 +350,7 @@
Uint32 curtic = SDL_GetTicks();
Uint32 delta = curtic - lasttic;
- while (delta >= joy_pollrate) {
+ while (delta >= (uint)joy_pollrate) {
joy_process(delta);
lasttic += joy_pollrate;
Index: src/ship/aicode.cpp
===================================================================
RCS file: /cvs/cvsroot/freespace2/src/ship/aicode.cpp,v
retrieving revision 1.7
diff -u -r1.7 aicode.cpp
--- src/ship/aicode.cpp 2003/05/25 02:30:43 1.7
+++ src/ship/aicode.cpp 2003/08/01 03:08:00
@@ -4137,7 +4137,7 @@
pnode *pn = &Path_points[path_cur];
ship_info *sip = &Ship_info[Ships[Objects[goal_objnum].instance].ship_info_index];
polymodel *pm = model_get(sip->modelnum);
- static int debug_last_index = -1;
+ //static int debug_last_index = -1; // no longer used
*pmpv = NULL;
*pmp = NULL;
Index: src/ship/aigoals.cpp
===================================================================
RCS file: /cvs/cvsroot/freespace2/src/ship/aigoals.cpp,v
retrieving revision 1.4
diff -u -r1.4 aigoals.cpp
--- src/ship/aigoals.cpp 2002/06/09 04:41:26 1.4
+++ src/ship/aigoals.cpp 2003/08/01 03:08:01
@@ -1914,6 +1914,7 @@
}
//XSTR:OFF
+/* Not used, debugging stuff
static char *Goal_text[5] = {
"EVENT_SHIP",
"EVENT_WING",
@@ -1921,6 +1922,7 @@
"PLAYER_WING",
"DYNAMIC",
};
+*/
//XSTR:ON
extern char *Mode_text[MAX_AI_BEHAVIORS];
Index: src/sound/audiostr.cpp
===================================================================
RCS file: /cvs/cvsroot/freespace2/src/sound/audiostr.cpp,v
retrieving revision 1.5
diff -u -r1.5 audiostr.cpp
--- src/sound/audiostr.cpp 2002/06/09 04:41:26 1.5
+++ src/sound/audiostr.cpp 2003/08/01 03:08:01
@@ -1547,14 +1547,14 @@
void audiostream_init()
{
- int i;
-
if ( Audiostream_inited == 1 )
return;
#ifdef PLAT_UNIX
STUB_FUNCTION;
#else
+ int i;
+
if ( !ACM_is_inited() ) {
return;
}
@@ -1614,13 +1614,14 @@
// be used.
void audiostream_close()
{
- int i;
if ( Audiostream_inited == 0 )
return;
#ifdef PLAT_UNIX
STUB_FUNCTION;
#else
+ int i;
+
for ( i = 0; i < MAX_AUDIO_STREAMS; i++ ) {
if ( Audio_streams[i].status == ASF_USED ) {
Audio_streams[i].status = ASF_FREE;
@@ -1993,14 +1994,14 @@
// unpause the audio stream identified by handle i.
void audiostream_unpause(int i)
{
- int is_looping;
-
if ( i == -1 )
return;
#ifdef PLAT_UNIX
STUB_FUNCTION;
#else
+ int is_looping;
+
Assert( i >= 0 && i < MAX_AUDIO_STREAMS );
if ( Audio_streams[i].status == ASF_FREE )
return;
Index: src/sound/ds.cpp
===================================================================
RCS file: /cvs/cvsroot/freespace2/src/sound/ds.cpp,v
retrieving revision 1.15
diff -u -r1.15 ds.cpp
--- src/sound/ds.cpp 2003/03/15 05:12:56 1.15
+++ src/sound/ds.cpp 2003/08/01 03:08:02
@@ -546,6 +546,13 @@
static int Ds_use_a3d = 0;
static int Ds_use_eax = 0;
+static int AL_play_position = 0;
+
+#ifndef AL_BYTE_LOKI
+// in case it's not defined by older/other drivers
+#define AL_BYTE_LOKI 0x100C
+#endif
+
ALCdevice *ds_sound_device;
void *ds_sound_context = (void *)0;
@@ -604,6 +611,11 @@
return ds_is_3d_buffer(ds_software_buffers[sid].pdsb);
}
#else
+ // they are all 3d
+ if ( sid >= 0 ) {
+ return 1;
+ }
+
return 0;
#endif
}
@@ -1402,13 +1414,23 @@
}
OpenAL_ErrorCheck();
-
+
+ // make sure we can actually use AL_BYTE_LOKI (Mac OpenAL doesn't have it)
+ AL_play_position = alIsExtensionPresent( (ALubyte*)"AL_LOKI_play_position" );
+
// Initialize DirectSound3D. Since software performance of DirectSound3D is unacceptably
// slow, we require the voice manger (a DirectSound extension) to be present. The
// exception is when A3D is being used, since A3D has a resource manager built in.
// if (Ds_use_ds3d && ds3d_init(0) != 0)
// Ds_use_ds3d = 0;
+ // setup default listener position/orientation
+ // this is needed for 2D pan
+ alListener3f(AL_POSITION, 0.0, 0.0, 0.0);
+
+ ALfloat list_orien[] = { 0.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f };
+ alListenerfv(AL_ORIENTATION, list_orien);
+
ds_build_vol_lookup();
ds_init_channels();
ds_init_buffers();
@@ -1971,7 +1993,7 @@
continue;
}
- alGetSourceiv(chp->source_id, AL_SOURCE_STATE, &status);
+ alGetSourcei(chp->source_id, AL_SOURCE_STATE, &status);
OpenAL_ErrorCheck();
@@ -2455,9 +2477,17 @@
Channels[channel].looping = looping;
Channels[channel].priority = priority;
- /* TODO: pan */
- // Channels[channel].pdsb->SetPan(pan);
-
+ // set the new pan or default
+ ALfloat alpan = (pan != 0) ? ((float)pan / MAX_PAN) : 0.0f;
+ alSource3f(Channels[channel].source_id, AL_POSITION, alpan, 0.0f, 1.0f);
+
+ OpenAL_ErrorCheck();
+
+ // reset to deafult pitch value
+ alSourcef(Channels[channel].source_id, AL_PITCH, 1.0);
+
+ OpenAL_ErrorCheck();
+
ALfloat alvol = (volume != -10000) ? pow(10.0, (float)volume / (-600.0 / log10(.5))): 0.0;
alSourcef(Channels[channel].source_id, AL_GAIN, alvol);
@@ -2466,7 +2496,7 @@
OpenAL_ErrorCheck();
ALint status;
- alGetSourceiv(Channels[channel].source_id, AL_SOURCE_STATE, &status);
+ alGetSourcei(Channels[channel].source_id, AL_SOURCE_STATE, &status);
OpenAL_ErrorCheck();
@@ -2510,7 +2540,6 @@
continue;
}
-#ifndef PLAT_UNIX /* TODO: play position still needs some work */
DWORD current_position = ds_get_play_position(i);
if (current_position != 0) {
if (current_position < Channels[i].last_position) {
@@ -2518,8 +2547,7 @@
} else {
Channels[i].last_position = current_position;
}
- }
-#endif
+ }
}
}
@@ -2630,7 +2658,6 @@
continue;
}
-#ifndef PLAT_UNIX /* TODO: play position still needs some work */
DWORD current_position = ds_get_play_position(i);
if (current_position != 0) {
if (current_position < Channels[i].last_position) {
@@ -2638,8 +2665,7 @@
} else {
Channels[i].last_position = current_position;
}
- }
-#endif
+ }
}
}
@@ -2692,7 +2718,7 @@
if ( Channels[channel].source_id != 0 ) {
ALint status;
- alGetSourceiv(Channels[channel].source_id, AL_SOURCE_STATE, &status);
+ alGetSourcei(Channels[channel].source_id, AL_SOURCE_STATE, &status);
OpenAL_ErrorCheck();
return (status == AL_PLAYING);
@@ -2802,7 +2828,14 @@
void ds_set_pan( int channel, int pan )
{
#ifdef PLAT_UNIX
- STUB_FUNCTION;
+ ALint state;
+
+ alGetSourcei(Channels[channel].source_id, AL_SOURCE_STATE, &state);
+
+ if (state == AL_PLAYING) {
+ ALfloat alpan = (pan != 0) ? ((float)pan / MAX_PAN) : 0.0;
+ alSource3f(Channels[channel].source_id, AL_POSITION, alpan, 0.0, 1.0);
+ }
#else
HRESULT hr;
unsigned long status;
@@ -2827,9 +2860,19 @@
int ds_get_pitch(int channel)
{
#ifdef PLAT_UNIX
- STUB_FUNCTION;
+ ALint status;
+ ALfloat alpitch = 0;
+ int pitch;
- return -1;
+ alGetSourcei(Channels[channel].source_id, AL_SOURCE_STATE, &status);
+
+ if (status == AL_PLAYING)
+ alGetSourcef(Channels[channel].source_id, AL_PITCH, &alpitch);
+
+ // convert OpenAL values to DirectSound values and return
+ pitch = fl2i( pow(10.0, (alpitch + 2.0)) );
+
+ return pitch;
#else
unsigned long status, pitch = 0;
HRESULT hr;
@@ -2861,7 +2904,20 @@
void ds_set_pitch(int channel, int pitch)
{
#ifdef PLAT_UNIX
- STUB_FUNCTION;
+ ALint status;
+
+ if ( pitch < MIN_PITCH )
+ pitch = MIN_PITCH;
+
+ if ( pitch > MAX_PITCH )
+ pitch = MAX_PITCH;
+
+ alGetSourcei(Channels[channel].source_id, AL_SOURCE_STATE, &status);
+
+ if (status == AL_PLAYING) {
+ ALfloat alpitch = log10(pitch) - 2.0;
+ alSourcef(Channels[channel].source_id, AL_PITCH, alpitch);
+ }
#else
unsigned long status;
HRESULT hr;
@@ -3113,11 +3169,14 @@
#ifdef PLAT_UNIX
ALint pos;
- /* TODO: does this work ? */
- alGetSourceiv(Channels[channel].source_id, AL_BYTE_LOKI, &pos);
-
- if (pos == -1)
+ if (!AL_play_position)
return 0;
+
+ alGetSourcei(Channels[channel].source_id, AL_BYTE_LOKI, &pos);
+
+ if ( pos < 0 )
+ pos = 0;
+
return pos;
#else
DWORD play,write;
@@ -3642,12 +3701,11 @@
for (int i=0; i<MAX_CHANNELS; i++) {
cp = &Channels[i];
- if (cp->is_voice_msg) {
+ if (cp->is_voice_msg == true) {
if (cp->source_id == 0) {
continue;
}
-#ifndef PLAT_UNIX /* TODO: get play position needs some work */
int current_position = ds_get_play_position(i);
if (current_position != 0) {
if (current_position < cp->last_position) {
@@ -3660,7 +3718,6 @@
cp->last_position = current_position;
}
}
-#endif
}
}
}
Index: src/stats/medals.cpp
===================================================================
RCS file: /cvs/cvsroot/freespace2/src/stats/medals.cpp,v
retrieving revision 1.10
diff -u -r1.10 medals.cpp
--- src/stats/medals.cpp 2003/06/11 18:30:33 1.10
+++ src/stats/medals.cpp 2003/08/01 03:08:03
@@ -392,7 +392,7 @@
static bitmap *Medals_mask;
int Medals_mask_w, Medals_mask_h;
-static int Medal_palette; // Medal palette bitmap
+//static int Medal_palette; // Medal palette bitmap - no longer used
static int Medals_bitmap_mask; // the mask for the medal case
static int Medals_bitmap; // the medal case itself
static int Medal_bitmaps[NUM_MEDALS]; // bitmaps for the individual medals
More information about the freespace2
mailing list