diff --git a/changelog.log b/changelog.log index 458e221f..f7207beb 100644 --- a/changelog.log +++ b/changelog.log @@ -4,43 +4,24 @@ Заменить все нелогичные Com_Error\Sys_Error на варнинги render.dll -1. убрать все типы float, кроме ABGR128 OK -2. Избавиться от pcx совсем -3. упорядочить типы загрузки ОК -4. избавиться от LightImageScale -5. переименовать в renderer.dll +1. Избавиться от pcx совсем +2. избавиться от LightImageScale engine.dll -1. избавиться от Com_Sprintf OK -2. убить все ссылки на .md2(заменить на mdl) -3. подгрузка дллок из base\game директории OK -4. переписать парсинг scripts\maps.txt -5. убить поддержку cd - -launcher.dll -1. перенести лог в лаунчер OK +1. убить все ссылки на .md2(заменить на mdl) +2. переписать парсинг scripts\maps.txt platform.dll -1. Запись файлов должна идти в game директорию ОК -2. Сделать валидатор game-директорий ОК -3. Переписать валидатор-финдер game directory ОК -4. Переписать SC_ParseToken -5. Не работает MsgDev OK -6. научить GetToken распознaвать \r +1. сделать парсинг "ambient" из карты +2. сделать новый contents для Null +3. научить rad суммировать цвета в dxt -{ - studiomdl - апгрейд до версии 0.2 - 1. Окончательно настроить все лимиты - - bsplib - 1. сделать парсинг "ambient" из карты - 2. сделать новый contents для Null - 3. научить rad суммировать цвета в dxt -} //================================================== // то, что уже готово //================================================== ++исправлены баги со studiomdl ++убраны лишние пункты в меню +исправлен баг с вылетом рендерера +пофикшен баг с автоматическим рассчетом хулла для первой энтити на карте +существенное уменьшение размера сейвов diff --git a/debug.bat b/debug.bat index 96bd0fe7..ac98d543 100644 --- a/debug.bat +++ b/debug.bat @@ -20,7 +20,7 @@ if errorlevel 1 set BUILD_ERROR=1 %MSDEV% platform/platform.dsp %CONFIG%"platform - Win32 Debug" %build_target% if errorlevel 1 set BUILD_ERROR=1 -%MSDEV% render/render.dsp %CONFIG%"render - Win32 Debug" %build_target% +%MSDEV% renderer/renderer.dsp %CONFIG%"renderer - Win32 Debug" %build_target% if errorlevel 1 set BUILD_ERROR=1 %MSDEV% server/server.dsp %CONFIG%"server - Win32 Debug" %build_target% @@ -48,7 +48,7 @@ rem //delete log files if exist engine\engine.plg del /f /q engine\engine.plg if exist launcher\launcher.plg del /f /q launcher\launcher.plg if exist platform\platform.plg del /f /q platform\platform.plg -if exist render\render.plg del /f /q render\render.plg +if exist renderer\renderer.plg del /f /q renderer\renderer.plg if exist server\server.plg del /f /q server\server.plg echo Build succeeded! diff --git a/editor/editor.plg b/editor/editor.plg index c4f5bf9d..cb2e0b18 100644 --- a/editor/editor.plg +++ b/editor/editor.plg @@ -3,36 +3,9 @@
 

Build Log

---------------------Configuration: editor - Win32 Debug-------------------- +--------------------Configuration: editor - Win32 Release--------------------

Command Lines

-Creating temporary file "C:\Temp\RSP1739.tmp" with contents -[ -/nologo /MTd /W3 /Gm /Gi /GX /ZI /Od /I "../public" /I "../platform/formats" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR"..\temp\editor\!debug/" /Fo"..\temp\editor\!debug/" /Fd"..\temp\editor\!debug/" /FD /GZ /c -"D:\XASH3D\src_main\!source\editor\guiforms.c" -] -Creating command line "cl.exe @C:\Temp\RSP1739.tmp" -Creating temporary file "C:\Temp\RSP173A.tmp" with contents -[ -kernel32.lib user32.lib gdi32.lib comctl32.lib comdlg32.lib /nologo /dll /incremental:yes /pdb:"..\temp\editor\!debug/editor.pdb" /debug /machine:I386 /out:"..\temp\editor\!debug/editor.dll" /implib:"..\temp\editor\!debug/editor.lib" /pdbtype:sept -"\XASH3D\src_main\!source\temp\editor\!debug\editor.obj" -"\XASH3D\src_main\!source\temp\editor\!debug\guiutils.obj" -"\XASH3D\src_main\!source\temp\editor\!debug\guiforms.obj" -"\XASH3D\src_main\!source\temp\editor\!debug\editor.res" -] -Creating command line "link.exe @C:\Temp\RSP173A.tmp" -Creating temporary file "C:\Temp\RSP173B.bat" with contents -[ -@echo off -copy \XASH3D\src_main\!source\temp\editor\!debug\editor.dll "D:\Xash3D\bin\editor.dll" -] -Creating command line "C:\Temp\RSP173B.bat" -Compiling... -guiforms.c -Linking... -

Output Window

-Performing Custom Build Step on \XASH3D\src_main\!source\temp\editor\!debug\editor.dll -‘Є®ЇЁа®ў ­® д ©«®ў: 1. diff --git a/engine/client/cl_ents.c b/engine/client/cl_ents.c index c3fba6cb..b31c59ba 100644 --- a/engine/client/cl_ents.c +++ b/engine/client/cl_ents.c @@ -24,10 +24,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. extern struct model_s *cl_mod_powerscreen; -//PGM -int vidref_val; -//PGM - /* ========================================================================= @@ -1203,12 +1199,8 @@ void CL_AddPacketEntities (frame_t *frame) float intensity; intensity = 50 + (500 * (sin(cl.time/500.0) + 1.0)); - // FIXME - check out this effect in rendition - if(vidref_val == VIDREF_GL) - V_AddLight (ent.origin, intensity, -1.0, -1.0, -1.0); - else - V_AddLight (ent.origin, -1.0 * intensity, 1.0, 1.0, 1.0); - } + V_AddLight (ent.origin, intensity, -1.0, -1.0, -1.0); + } else { CL_Tracker_Shell (cent->lerp_origin); @@ -1218,14 +1210,8 @@ void CL_AddPacketEntities (frame_t *frame) else if (effects & EF_TRACKER) { CL_TrackerTrail (cent->lerp_origin, ent.origin, 0); - // FIXME - check out this effect in rendition - if(vidref_val == VIDREF_GL) - V_AddLight (ent.origin, 200, -1, -1, -1); - else - V_AddLight (ent.origin, -200, 1, 1, 1); + V_AddLight (ent.origin, 200, -1, -1, -1); } -//ROGUE -//====== // RAFAEL else if (effects & EF_GREENGIB) { diff --git a/engine/client/cl_fx.c b/engine/client/cl_fx.c index 0a5cd9c6..51402d30 100644 --- a/engine/client/cl_fx.c +++ b/engine/client/cl_fx.c @@ -816,39 +816,11 @@ void CL_AddDLights (void) dl = cl_dlights; -//===== -//PGM - if(vidref_val == VIDREF_GL) + for (i = 0; i < MAX_DLIGHTS; i++, dl++) { - for (i=0 ; iradius) - continue; - V_AddLight (dl->origin, dl->radius, - dl->color[0], dl->color[1], dl->color[2]); - } + if (!dl->radius) continue; + V_AddLight (dl->origin, dl->radius, dl->color[0], dl->color[1], dl->color[2]); } - else - { - for (i=0 ; iradius) - continue; - - // negative light in software. only black allowed - if ((dl->color[0] < 0) || (dl->color[1] < 0) || (dl->color[2] < 0)) - { - dl->radius = -(dl->radius); - dl->color[0] = 1; - dl->color[1] = 1; - dl->color[2] = 1; - } - V_AddLight (dl->origin, dl->radius, - dl->color[0], dl->color[1], dl->color[2]); - } - } -//PGM -//===== } diff --git a/engine/client/cl_main.c b/engine/client/cl_main.c index 94050ce8..c289914f 100644 --- a/engine/client/cl_main.c +++ b/engine/client/cl_main.c @@ -1831,7 +1831,7 @@ void CL_Shutdown(void) S_Shutdown(); IN_Shutdown (); - VID_Shutdown(); + VID_FreeRenderer(); } diff --git a/engine/client/cl_newfx.c b/engine/client/cl_newfx.c index 67048867..5d753e3c 100644 --- a/engine/client/cl_newfx.c +++ b/engine/client/cl_newfx.c @@ -24,8 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. extern cparticle_t *active_particles, *free_particles; extern cparticle_t particles[MAX_PARTICLES]; -extern int cl_numparticles; -extern cvar_t *vid_ref; +extern int cl_numparticles; extern void MakeNormalVectors (vec3_t forward, vec3_t right, vec3_t up); @@ -97,14 +96,6 @@ void CL_ColorFlash (vec3_t pos, int ent, int intensity, float r, float g, float { cdlight_t *dl; - if((vidref_val == VIDREF_SOFT) && ((r < 0) || (g<0) || (b<0))) - { - intensity = -intensity; - r = -r; - g = -g; - b = -b; - } - dl = CL_AllocDlight (ent); VectorCopy (pos, dl->origin); dl->radius = intensity; @@ -547,24 +538,18 @@ void CL_Heatbeam (vec3_t start, vec3_t forward) VectorSubtract (end, start, vec); len = VectorNormalize (vec); - // FIXME - pmm - these might end up using old values? -// MakeNormalVectors (vec, right, up); VectorCopy (cl.v_right, right); VectorCopy (cl.v_up, up); - if (vidref_val == VIDREF_GL) - { // GL mode - VectorMA (move, -0.5, right, move); - VectorMA (move, -0.5, up, move); - } - // otherwise assume SOFT + VectorMA (move, -0.5, right, move); + VectorMA (move, -0.5, up, move); + // otherwise assume SOFT ltime = (float) cl.time/1000.0; start_pt = fmod(ltime*96.0,step); VectorMA (move, start_pt, vec, move); VectorScale (vec, step, vec); -// Msg ("%f\n", ltime); rstep = M_PI/10.0; for (i=start_pt ; ivalue ) * 2; Cvar_SetValue( "cl_run", ClampCvar( 0, 1, cl_run->value ) ); @@ -1101,8 +1092,6 @@ static void ControlsSetMenuItemValues( void ) Cvar_SetValue( "in_joystick", ClampCvar( 0, 1, in_joystick->value ) ); s_options_joystick_box.curvalue = in_joystick->value; - - s_options_noalttab_box.curvalue = win_noalttab->value; } static void ControlsResetDefaultsFunc( void *unused ) @@ -1133,11 +1122,6 @@ static void UpdateVolumeFunc( void *unused ) Cvar_SetValue( "s_volume", s_options_sfxvolume_slider.curvalue / 10 ); } -static void UpdateCDVolumeFunc( void *unused ) -{ - Cvar_SetValue( "cd_nocd", !s_options_cdvolume_box.curvalue ); -} - static void ConsoleFunc( void *unused ) { /* @@ -1186,12 +1170,6 @@ static void UpdateSoundQualityFunc( void *unused ) void Options_MenuInit( void ) { - static const char *cd_music_items[] = - { - "disabled", - "enabled", - 0 - }; static const char *quality_items[] = { "low", "high", 0 @@ -1218,8 +1196,6 @@ void Options_MenuInit( void ) 0 }; - win_noalttab = Cvar_Get( "win_noalttab", "0", CVAR_ARCHIVE ); - /* ** configure controls menu and menu items */ @@ -1231,22 +1207,14 @@ void Options_MenuInit( void ) s_options_sfxvolume_slider.generic.x = 0; s_options_sfxvolume_slider.generic.y = 0; s_options_sfxvolume_slider.generic.name = "effects volume"; - s_options_sfxvolume_slider.generic.callback = UpdateVolumeFunc; - s_options_sfxvolume_slider.minvalue = 0; - s_options_sfxvolume_slider.maxvalue = 10; - s_options_sfxvolume_slider.curvalue = Cvar_VariableValue( "s_volume" ) * 10; - - s_options_cdvolume_box.generic.type = MTYPE_SPINCONTROL; - s_options_cdvolume_box.generic.x = 0; - s_options_cdvolume_box.generic.y = 10; - s_options_cdvolume_box.generic.name = "CD music"; - s_options_cdvolume_box.generic.callback = UpdateCDVolumeFunc; - s_options_cdvolume_box.itemnames = cd_music_items; - s_options_cdvolume_box.curvalue = !Cvar_VariableValue("cd_nocd"); + s_options_sfxvolume_slider.generic.callback = UpdateVolumeFunc; + s_options_sfxvolume_slider.minvalue = 0; + s_options_sfxvolume_slider.maxvalue = 10; + s_options_sfxvolume_slider.curvalue = Cvar_VariableValue( "s_volume" ) * 10; s_options_quality_list.generic.type = MTYPE_SPINCONTROL; s_options_quality_list.generic.x = 0; - s_options_quality_list.generic.y = 20;; + s_options_quality_list.generic.y = 10; s_options_quality_list.generic.name = "sound quality"; s_options_quality_list.generic.callback = UpdateSoundQualityFunc; s_options_quality_list.itemnames = quality_items; @@ -1254,7 +1222,7 @@ void Options_MenuInit( void ) s_options_compatibility_list.generic.type = MTYPE_SPINCONTROL; s_options_compatibility_list.generic.x = 0; - s_options_compatibility_list.generic.y = 30; + s_options_compatibility_list.generic.y = 20; s_options_compatibility_list.generic.name = "sound compatibility"; s_options_compatibility_list.generic.callback = UpdateSoundQualityFunc; s_options_compatibility_list.itemnames = compatibility_items; @@ -1262,7 +1230,7 @@ void Options_MenuInit( void ) s_options_sensitivity_slider.generic.type = MTYPE_SLIDER; s_options_sensitivity_slider.generic.x = 0; - s_options_sensitivity_slider.generic.y = 50; + s_options_sensitivity_slider.generic.y = 40; s_options_sensitivity_slider.generic.name = "mouse speed"; s_options_sensitivity_slider.generic.callback = MouseSpeedFunc; s_options_sensitivity_slider.minvalue = 2; @@ -1270,56 +1238,49 @@ void Options_MenuInit( void ) s_options_alwaysrun_box.generic.type = MTYPE_SPINCONTROL; s_options_alwaysrun_box.generic.x = 0; - s_options_alwaysrun_box.generic.y = 60; + s_options_alwaysrun_box.generic.y = 50; s_options_alwaysrun_box.generic.name = "always run"; s_options_alwaysrun_box.generic.callback = AlwaysRunFunc; s_options_alwaysrun_box.itemnames = yesno_names; s_options_invertmouse_box.generic.type = MTYPE_SPINCONTROL; s_options_invertmouse_box.generic.x = 0; - s_options_invertmouse_box.generic.y = 70; + s_options_invertmouse_box.generic.y = 60; s_options_invertmouse_box.generic.name = "invert mouse"; s_options_invertmouse_box.generic.callback = InvertMouseFunc; s_options_invertmouse_box.itemnames = yesno_names; s_options_lookspring_box.generic.type = MTYPE_SPINCONTROL; s_options_lookspring_box.generic.x = 0; - s_options_lookspring_box.generic.y = 80; + s_options_lookspring_box.generic.y = 70; s_options_lookspring_box.generic.name = "lookspring"; s_options_lookspring_box.generic.callback = LookspringFunc; s_options_lookspring_box.itemnames = yesno_names; s_options_lookstrafe_box.generic.type = MTYPE_SPINCONTROL; s_options_lookstrafe_box.generic.x = 0; - s_options_lookstrafe_box.generic.y = 90; + s_options_lookstrafe_box.generic.y = 80; s_options_lookstrafe_box.generic.name = "lookstrafe"; s_options_lookstrafe_box.generic.callback = LookstrafeFunc; s_options_lookstrafe_box.itemnames = yesno_names; s_options_freelook_box.generic.type = MTYPE_SPINCONTROL; s_options_freelook_box.generic.x = 0; - s_options_freelook_box.generic.y = 100; + s_options_freelook_box.generic.y = 90; s_options_freelook_box.generic.name = "free look"; s_options_freelook_box.generic.callback = FreeLookFunc; s_options_freelook_box.itemnames = yesno_names; s_options_crosshair_box.generic.type = MTYPE_SPINCONTROL; s_options_crosshair_box.generic.x = 0; - s_options_crosshair_box.generic.y = 110; + s_options_crosshair_box.generic.y = 100; s_options_crosshair_box.generic.name = "crosshair"; s_options_crosshair_box.generic.callback = CrosshairFunc; s_options_crosshair_box.itemnames = crosshair_names; -/* - s_options_noalttab_box.generic.type = MTYPE_SPINCONTROL; - s_options_noalttab_box.generic.x = 0; - s_options_noalttab_box.generic.y = 110; - s_options_noalttab_box.generic.name = "disable alt-tab"; - s_options_noalttab_box.generic.callback = NoAltTabFunc; - s_options_noalttab_box.itemnames = yesno_names; -*/ + s_options_joystick_box.generic.type = MTYPE_SPINCONTROL; s_options_joystick_box.generic.x = 0; - s_options_joystick_box.generic.y = 120; + s_options_joystick_box.generic.y = 110; s_options_joystick_box.generic.name = "use joystick"; s_options_joystick_box.generic.callback = JoystickFunc; s_options_joystick_box.itemnames = yesno_names; @@ -1331,21 +1292,20 @@ void Options_MenuInit( void ) s_options_customize_options_action.generic.callback = CustomizeControlsFunc; s_options_defaults_action.generic.type = MTYPE_ACTION; - s_options_defaults_action.generic.x = 0; - s_options_defaults_action.generic.y = 150; + s_options_defaults_action.generic.x = 0; + s_options_defaults_action.generic.y = 150; s_options_defaults_action.generic.name = "reset defaults"; s_options_defaults_action.generic.callback = ControlsResetDefaultsFunc; s_options_console_action.generic.type = MTYPE_ACTION; - s_options_console_action.generic.x = 0; - s_options_console_action.generic.y = 160; + s_options_console_action.generic.x = 0; + s_options_console_action.generic.y = 160; s_options_console_action.generic.name = "go to console"; s_options_console_action.generic.callback = ConsoleFunc; ControlsSetMenuItemValues(); Menu_AddItem( &s_options_menu, ( void * ) &s_options_sfxvolume_slider ); - Menu_AddItem( &s_options_menu, ( void * ) &s_options_cdvolume_box ); Menu_AddItem( &s_options_menu, ( void * ) &s_options_quality_list ); Menu_AddItem( &s_options_menu, ( void * ) &s_options_compatibility_list ); Menu_AddItem( &s_options_menu, ( void * ) &s_options_sensitivity_slider ); @@ -2567,7 +2527,10 @@ void StartServer_MenuInit( void ) ** load the list of map names */ if(!FS_FileExists("scripts/maps.txt") && !CreateMapsList()) - Sys_Error("maps not found\n"); + { + MsgWarn("StartServer_MenuInit: maps.lst not found\n"); + return; + } fp = FS_Open( "scripts/maps.txt", "rb" ); FS_Seek(fp, 0, SEEK_END); diff --git a/engine/common/vid.h b/engine/common/vid.h index 4aaf36ef..02376409 100644 --- a/engine/common/vid.h +++ b/engine/common/vid.h @@ -28,15 +28,16 @@ typedef struct vrect_s typedef struct { - int width, height; // coordinates from main game + int width, height; // coordinates from main game } viddef_t; -extern viddef_t viddef; // global video state +extern viddef_t viddef; // global video state // Video module initialisation etc void VID_Init (void); -void VID_Shutdown (void); -void VID_CheckChanges (void); +void VID_InitRenderer(void); +void VID_FreeRenderer(void); +void VID_CheckChanges(void); void VID_MenuInit( void ); void VID_MenuDraw( void ); diff --git a/engine/host.c b/engine/host.c index 85b83453..16706445 100644 --- a/engine/host.c +++ b/engine/host.c @@ -44,18 +44,12 @@ void Host_InitPlatform( char *funcname, int argc, char **argv ) pistd.error = Sys_Error; if (( platform_dll = LoadLibrary( "bin/platform.dll" )) == 0 ) - { Sys_Error( "Couldn't load platform.dll\n" ); - return; - } if (( CreatePlat = (void *)GetProcAddress( platform_dll, "CreateAPI" ) ) == 0 ) - { - Sys_Error("can't init platform.dll\n"); - return; - } - pi = CreatePlat( pistd ); + Sys_Error("CreateInstance: %s has no valid entry point\n", "platform.dll" ); + pi = CreatePlat( pistd ); if(pi->apiversion != PLATFORM_API_VERSION) Sys_Error("mismatch version (%i should be %i)\n", pi->apiversion, PLATFORM_API_VERSION); @@ -90,8 +84,6 @@ void Host_Init (char *funcname, int argc, char **argv) char *s; global_hInstance = (HINSTANCE)GetModuleHandle( NULL ); - if (setjmp (abortframe)) Sys_Error ("Error during initialization"); - if(!strcmp(funcname, "host_dedicated"))is_dedicated = true; Host_InitPlatform( funcname, argc, argv ); @@ -111,11 +103,8 @@ void Host_Init (char *funcname, int argc, char **argv) Cbuf_AddEarlyCommands (false); Cbuf_Execute (); - //FS_InitFilesystem (); - Cbuf_AddText ("exec default.cfg\n"); Cbuf_AddText ("exec config.cfg\n"); - Cbuf_AddEarlyCommands (true); Cbuf_Execute (); @@ -270,7 +259,6 @@ void Host_Main( void ) newtime = Sys_Milliseconds (); time = newtime - oldtime; } while (time < 1); -// Msg ("time:%5.2f - %5.2f = %5.2f\n", newtime, oldtime, time); _controlfp( _PC_24, _MCW_PC ); Host_Frame (time); diff --git a/engine/server/sv_game.c b/engine/server/sv_game.c index 6dd0e11e..9290a933 100644 --- a/engine/server/sv_game.c +++ b/engine/server/sv_game.c @@ -24,7 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "server.h" game_export_t *ge; -extern HINSTANCE game_library; +HINSTANCE sv_library; /* =============== @@ -305,7 +305,7 @@ void SV_ShutdownGameProgs (void) { if (!ge) return; ge->Shutdown (); - Sys_UnloadGame (); + Sys_UnloadGame ( sv_library ); ge = NULL; } @@ -387,7 +387,7 @@ void SV_InitGameProgs (void) import.AreasConnected = CM_AreasConnected; //find server.dll - ge = (game_export_t *)Sys_GetGameAPI ("ServerAPI", &import); + ge = (game_export_t *)Sys_LoadGame("ServerAPI", sv_library, &import); if (!ge) Com_Error (ERR_DROP, "failed to load game DLL"); if (ge->apiversion != GAME_API_VERSION) diff --git a/engine/snd_dma.c b/engine/snd_dma.c index 6bbfb753..6f1a693d 100644 --- a/engine/snd_dma.c +++ b/engine/snd_dma.c @@ -207,34 +207,31 @@ sfx_t *S_FindName (char *name, bool create) int i; sfx_t *sfx; - if (!name) - Com_Error (ERR_FATAL, "S_FindName: NULL\n"); - if (!name[0]) - Com_Error (ERR_FATAL, "S_FindName: empty name\n"); - - if (strlen(name) >= MAX_QPATH) - Com_Error (ERR_FATAL, "Sound name too long: %s", name); + if (!name || !name[0]) return NULL; // see if already loaded - for (i=0 ; i < num_sfx ; i++) + for (i = 0; i < num_sfx; i++) + { if (!strcmp(known_sfx[i].name, name)) { return &known_sfx[i]; } - - if (!create) - return NULL; + } + if (!create) return NULL; // find a free sfx - for (i=0 ; i < num_sfx ; i++) + for (i = 0; i < num_sfx; i++) + { if (!known_sfx[i].name[0]) -// registration_sequence < s_registration_sequence) break; - + } if (i == num_sfx) { if (num_sfx == MAX_SFX) - Com_Error (ERR_FATAL, "S_FindName: out of sfx_t"); + { + MsgWarn("S_FindName: MAX_SFX limit exceeded\n"); + return NULL; + } num_sfx++; } @@ -270,7 +267,10 @@ sfx_t *S_AliasName (char *aliasname, char *truename) if (i == num_sfx) { if (num_sfx == MAX_SFX) - Com_Error (ERR_FATAL, "S_FindName: out of sfx_t"); + { + MsgWarn("S_AliasName: MAX_SFX limit exceeded\n"); + return NULL; + } num_sfx++; } @@ -306,14 +306,11 @@ sfx_t *S_RegisterSound (char *name) { sfx_t *sfx; - if (!sound_started) - return NULL; + if (!sound_started) return NULL; sfx = S_FindName (name, true); sfx->registration_sequence = s_registration_sequence; - - if (!s_registering) - S_LoadSound (sfx); + if (!s_registering) S_LoadSound (sfx); return sfx; } diff --git a/engine/snd_mem.c b/engine/snd_mem.c index 62b94a23..07e242df 100644 --- a/engine/snd_mem.c +++ b/engine/snd_mem.c @@ -211,12 +211,10 @@ void FindNextChunk(char *name) data_p = NULL; return; } -// if (iff_chunk_len > 1024*1024) -// Sys_Error ("FindNextChunk: %i length is past the 1 meg sanity limit", iff_chunk_len); + data_p -= 8; last_chunk = data_p + 8 + ( (iff_chunk_len + 1) & ~1 ); - if (!strncmp(data_p, name, 4)) - return; + if (!strncmp(data_p, name, 4)) return; } } diff --git a/engine/system.c b/engine/system.c index 4dca86a6..aab271b3 100644 --- a/engine/system.c +++ b/engine/system.c @@ -30,7 +30,6 @@ stdinout_api_t std; uint sys_msg_time; uint sys_frame_time; -bool s_win95; int starttime; /* @@ -89,10 +88,7 @@ void Sys_Init (void) vinfo.dwOSVersionInfoSize = sizeof(vinfo); if (!GetVersionEx (&vinfo)) Sys_Error ("Couldn't get OS info"); - if (vinfo.dwMajorVersion < 4) Sys_Error ("%s requires windows version 4 or greater", GI.title); - if (vinfo.dwPlatformId == VER_PLATFORM_WIN32s) Sys_Error ("%s doesn't run on Win32s", GI.title); - else if ( vinfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS ) s_win95 = true; } /* @@ -199,68 +195,68 @@ GAME DLL ======================================================================== */ - -HINSTANCE game_library; - /* ================= Sys_UnloadGame ================= */ -void Sys_UnloadGame (void) +void Sys_UnloadGame( void *hinstance ) { - if (!FreeLibrary (game_library)) - Com_Error (ERR_FATAL, "FreeLibrary failed for game library"); - game_library = NULL; + if(!hinstance) return; + FreeLibrary(hinstance); + hinstance = NULL; } /* ================= -Sys_GetGameAPI +Sys_LoadGame Loads the game dll ================= */ -void *Sys_GetGameAPI (const char* procname, void *parms) +void *Sys_LoadGame (const char* procname, void *hinstance, void *parms) { void *(*GetGameAPI) (void *); char basepath[MAX_SYSPATH]; search_t *gamedll; int i; - if (game_library) - Com_Error (ERR_FATAL, "Sys_GetGameAPI without Sys_UnloadingGame"); + Sys_UnloadGame( hinstance ); //find server.dll gamedll = FS_Search( "bin/*.dll" ); - if(!gamedll) Com_Error (ERR_DROP, "can't found game DLL"); + if(!gamedll) + { + Com_Error (ERR_DROP, "Can't find game.dll\n"); + return NULL; + } // now run through the search paths for( i = 0; i < gamedll->numfilenames; i++ ) { sprintf(basepath, "%s/%s", GI.gamedir, gamedll->filenames[i]); - game_library = LoadLibrary ( basepath ); + hinstance = LoadLibrary ( basepath ); - if (!game_library) + if (!hinstance) { sprintf(basepath, "%s/%s", GI.basedir, gamedll->filenames[i]); - game_library = LoadLibrary ( basepath ); + hinstance = LoadLibrary ( basepath ); } - if (game_library) + if (hinstance) { - if (( GetGameAPI = (void *)GetProcAddress( game_library, procname )) == 0 ) - Sys_UnloadGame(); + if (( GetGameAPI = (void *)GetProcAddress( hinstance, procname )) == 0 ) + Sys_UnloadGame( hinstance ); else break; } - else Msg("Can't loading %s\n", gamedll->filenames[i] ); + else MsgWarn("Can't loading %s\n", gamedll->filenames[i] ); } - GetGameAPI = (void *)GetProcAddress (game_library, procname ); + GetGameAPI = (void *)GetProcAddress (hinstance, procname ); if (!GetGameAPI) { - Sys_UnloadGame (); + Sys_UnloadGame( hinstance ); return NULL; } return GetGameAPI (parms); diff --git a/engine/vid_dll.c b/engine/vid_dll.c index cc8dfe52..0265bb60 100644 --- a/engine/vid_dll.c +++ b/engine/vid_dll.c @@ -27,8 +27,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Structure containing functions exported from refresh DLL renderer_exp_t *re; -cvar_t *win_noalttab; - extern HWND cl_hwnd; extern bool ActiveApp, Minimized; extern HINSTANCE global_hInstance; @@ -41,15 +39,15 @@ static UINT MSH_MOUSEWHEEL; // Console variables that we need to access from this module cvar_t *vid_gamma; -cvar_t *vid_ref; // Name of Refresh DLL loaded +cvar_t *vid_ref; // Name of Refresh DLL loaded cvar_t *vid_xpos; // X coordinate of window position cvar_t *vid_ypos; // Y coordinate of window position cvar_t *vid_fullscreen; // Global variables used internally by this module -viddef_t viddef; // global video state; used by other modules -HINSTANCE reflib_library; // Handle to refresh DLL -bool reflib_active = 0; +viddef_t viddef; // global video state; used by other modules +HINSTANCE renderer_dll; // Handle to refresh DLL +bool reflib_active = 0; HWND cl_hwnd; // Main window handle for life of program @@ -57,54 +55,9 @@ HWND cl_hwnd; // Main window handle for life of program LONG WINAPI MainWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ); -static bool s_alttab_disabled; extern unsigned sys_msg_time; -/* -** WIN32 helper functions -*/ -extern bool s_win95; - -static void WIN_DisableAltTab( void ) -{ - if ( s_alttab_disabled ) - return; - - if ( s_win95 ) - { - BOOL old; - - SystemParametersInfo( SPI_SCREENSAVERRUNNING, 1, &old, 0 ); - } - else - { - RegisterHotKey( 0, 0, MOD_ALT, VK_TAB ); - RegisterHotKey( 0, 1, MOD_ALT, VK_RETURN ); - } - s_alttab_disabled = true; -} - -static void WIN_EnableAltTab( void ) -{ - if ( s_alttab_disabled ) - { - if ( s_win95 ) - { - BOOL old; - - SystemParametersInfo( SPI_SCREENSAVERRUNNING, 0, &old, 0 ); - } - else - { - UnregisterHotKey( 0, 0 ); - UnregisterHotKey( 0, 1 ); - } - - s_alttab_disabled = false; - } -} - /* ========================================================================== @@ -247,20 +200,11 @@ void AppActivate(BOOL fActive, BOOL minimize) { IN_Activate (false); S_Activate (false); - - if ( win_noalttab->value ) - { - WIN_EnableAltTab(); - } } else { IN_Activate (true); S_Activate (true); - if ( win_noalttab->value ) - { - WIN_DisableAltTab(); - } } } @@ -454,16 +398,13 @@ typedef struct vidmode_s vidmode_t vid_modes[] = { { "Mode 0: 320x240", 320, 240, 0 }, - { "Mode 1: 400x300", 400, 300, 1 }, - { "Mode 2: 512x384", 512, 384, 2 }, - { "Mode 3: 640x480", 640, 480, 3 }, - { "Mode 4: 800x600", 800, 600, 4 }, - { "Mode 5: 960x720", 960, 720, 5 }, - { "Mode 6: 1024x768", 1024, 768, 6 }, - { "Mode 7: 1152x864", 1152, 864, 7 }, - { "Mode 8: 1280x960", 1280, 960, 8 }, - { "Mode 9: 1600x1200", 1600, 1200, 9 }, - { "Mode 10: 2048x1536", 2048, 1536, 10 } + { "Mode 1: 640x480", 640, 480, 1 }, + { "Mode 2: 800x600", 800, 600, 2 }, + { "Mode 3: 1024x768", 1024, 768, 3 }, + { "Mode 4: 1280x960", 1280, 960, 4 }, + { "Mode 5: 1280x1024", 1280, 1024, 5 }, + { "Mode 6: 1600x1200", 1600, 1200, 6 }, + { "Mode 7: 2048x1536", 2048, 1536, 7 } }; bool VID_GetModeInfo( int *width, int *height, int mode ) @@ -513,10 +454,9 @@ void VID_NewWindow ( int width, int height) void VID_FreeReflib (void) { - if ( !FreeLibrary( reflib_library ) ) - Com_Error( ERR_FATAL, "Reflib FreeLibrary failed" ); + FreeLibrary( renderer_dll ); memset (&re, 0, sizeof(re)); - reflib_library = NULL; + renderer_dll = NULL; reflib_active = false; } @@ -532,30 +472,16 @@ char *FS_Title( void ) /* ============== -VID_LoadRefresh +VID_InitRenderer ============== */ -bool VID_LoadRefresh( char *name ) +void VID_InitRenderer( void ) { renderer_imp_t ri; renderer_t CreateRender; - if ( reflib_active ) - { - re->Shutdown(); - VID_FreeReflib (); - } + VID_FreeRenderer(); - Msg( "------- Loading %s -------\n", name ); - - if ( ( reflib_library = LoadLibrary( name ) ) == 0 ) - { - Msg( "LoadLibrary(\"%s\") failed\n", name ); - - return false; - } - - // load a new game dll ri.Fs = pi->Fs; ri.VFs = pi->VFs; ri.Mem = pi->Mem; @@ -580,42 +506,25 @@ bool VID_LoadRefresh( char *name ) // studio callbacks ri.StudioEvent = CL_StudioEvent; + + if(( renderer_dll = LoadLibrary( "bin/renderer.dll" )) == 0 ) + Sys_Error( "Couldn't load renderer.dll\n" ); - if ( ( CreateRender = (void *) GetProcAddress( reflib_library, "CreateAPI" ) ) == 0 ) - Com_Error( ERR_FATAL, "GetProcAddress failed on %s", name ); + if ( ( CreateRender = (void *) GetProcAddress( renderer_dll, "CreateAPI" )) == 0 ) + Sys_Error( "CreateInstance: %s has no valid entry point", "renderer.dll" ); re = CreateRender( ri ); - if (re->apiversion != RENDERER_API_VERSION) - { - VID_FreeReflib (); - Com_Error (ERR_FATAL, "%s has incompatible api_version", name); - } + if(re->apiversion != RENDERER_API_VERSION) + Sys_Error("mismatch version (%i should be %i)\n", re->apiversion, RENDERER_API_VERSION); + + if(re->api_size != sizeof(renderer_exp_t)) + Sys_Error("mismatch interface size (%i should be %i)\n", re->api_size, sizeof(renderer_exp_t)); - if ( re->Init( global_hInstance, MainWndProc ) == -1 ) - { - re->Shutdown(); - VID_FreeReflib (); - return false; - } + if(!re->Init( global_hInstance, MainWndProc )) + Sys_Error("can't init renderer.dll\n"); - Msg( "------------------------------------\n"); reflib_active = true; - -//====== -//PGM - vidref_val = VIDREF_OTHER; - if(vid_ref) - { - if(!strcmp (vid_ref->string, "gl")) - vidref_val = VIDREF_GL; - else if(!strcmp(vid_ref->string, "soft")) - vidref_val = VIDREF_SOFT; - } -//PGM -//====== - - return true; } /* @@ -629,22 +538,9 @@ update the rendering DLL and/or video mode to match. */ void VID_CheckChanges (void) { - if ( win_noalttab->modified ) - { - if ( win_noalttab->value ) - { - WIN_DisableAltTab(); - } - else - { - WIN_EnableAltTab(); - } - win_noalttab->modified = false; - } - if ( vid_ref->modified ) { - cl.force_refdef = true; // can't use a paused refdef + cl.force_refdef = true; // can't use a paused refdef S_StopAllSounds(); } while (vid_ref->modified) @@ -657,26 +553,11 @@ void VID_CheckChanges (void) cl.refresh_prepped = false; cls.disable_screen = true; - if ( !VID_LoadRefresh( "bin/render.dll" ) ) - { - if ( strcmp (vid_ref->string, "soft") == 0 ) - Com_Error (ERR_FATAL, "Couldn't fall back to software refresh!"); - Cvar_Set( "vid_ref", "soft" ); - - /* - ** drop the console if we fail to load a refresh - */ - if ( cls.key_dest != key_console ) - { - Con_ToggleConsole_f(); - } - } + VID_InitRenderer(); cls.disable_screen = false; } - /* - ** update our window position - */ + // update our window position if ( vid_xpos->modified || vid_ypos->modified ) { if (!vid_fullscreen->value) @@ -695,47 +576,26 @@ VID_Init void VID_Init (void) { /* Create the video variables so we know how to start the graphics drivers */ - vid_ref = Cvar_Get ("vid_ref", "soft", CVAR_ARCHIVE); + vid_ref = Cvar_Get ("vid_ref", "gl", CVAR_ARCHIVE); vid_xpos = Cvar_Get ("vid_xpos", "3", CVAR_ARCHIVE); vid_ypos = Cvar_Get ("vid_ypos", "22", CVAR_ARCHIVE); vid_fullscreen = Cvar_Get ("vid_fullscreen", "0", CVAR_ARCHIVE); vid_gamma = Cvar_Get( "vid_gamma", "1", CVAR_ARCHIVE ); - win_noalttab = Cvar_Get( "win_noalttab", "0", CVAR_ARCHIVE ); /* Add some console commands that we want to handle */ Cmd_AddCommand ("vid_restart", VID_Restart_f); Cmd_AddCommand ("vid_front", VID_Front_f); - - /* - ** this is a gross hack but necessary to clamp the mode for 3Dfx - */ -#if 0 - { - cvar_t *gl_driver = Cvar_Get( "gl_driver", "opengl32", 0 ); - cvar_t *gl_mode = Cvar_Get( "gl_mode", "3", 0 ); - - if ( stricmp( gl_driver->string, "3dfxgl" ) == 0 ) - { - Cvar_SetValue( "gl_mode", 3 ); - viddef.width = 640; - viddef.height = 480; - } - } -#endif - - /* Disable the 3Dfx splash screen */ - putenv("FX_GLIDE_NO_SPLASH=0"); - /* Start the graphics mode and load refresh DLL */ + // Start the graphics mode and load refresh DLL VID_CheckChanges(); } /* ============ -VID_Shutdown +VID_FreeRenderer ============ */ -void VID_Shutdown (void) +void VID_FreeRenderer (void) { if ( reflib_active ) { diff --git a/engine/vid_menu.c b/engine/vid_menu.c index e367a9c9..8505ee08 100644 --- a/engine/vid_menu.c +++ b/engine/vid_menu.c @@ -20,26 +20,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "client.h" #include "qmenu.h" -#define REF_SOFT 0 -#define REF_OPENGL 1 -#define REF_3DFX 2 -#define REF_POWERVR 3 -#define REF_VERITE 4 - -extern cvar_t *vid_ref; extern cvar_t *vid_fullscreen; extern cvar_t *vid_gamma; extern cvar_t *scr_viewsize; static cvar_t *gl_mode; -static cvar_t *gl_driver; static cvar_t *gl_picmip; static cvar_t *gl_ext_palettedtexture; static cvar_t *gl_finish; -static cvar_t *sw_mode; -static cvar_t *sw_stipplealpha; - extern void M_ForceMenuOff( void ); /* @@ -49,65 +38,31 @@ MENU INTERACTION ==================================================================== */ -#define SOFTWARE_MENU 0 -#define OPENGL_MENU 1 -static menuframework_s s_software_menu; -static menuframework_s s_opengl_menu; -static menuframework_s *s_current_menu; -static int s_current_menu_index; - -static menulist_s s_mode_list[2]; -static menulist_s s_ref_list[2]; +static menuframework_s s_video_menu; +static menulist_s s_mode_list; static menuslider_s s_tq_slider; -static menuslider_s s_screensize_slider[2]; -static menuslider_s s_brightness_slider[2]; -static menulist_s s_fs_box[2]; +static menuslider_s s_screensize_slider; +static menuslider_s s_brightness_slider; +static menulist_s s_fs_box; static menulist_s s_stipple_box; static menulist_s s_paletted_texture_box; static menulist_s s_finish_box; -static menuaction_s s_cancel_action[2]; -static menuaction_s s_defaults_action[2]; - -static void DriverCallback( void *unused ) -{ - s_ref_list[!s_current_menu_index].curvalue = s_ref_list[s_current_menu_index].curvalue; - - if ( s_ref_list[s_current_menu_index].curvalue == 0 ) - { - s_current_menu = &s_software_menu; - s_current_menu_index = 0; - } - else - { - s_current_menu = &s_opengl_menu; - s_current_menu_index = 1; - } - -} +static menuaction_s s_cancel_action; +static menuaction_s s_defaults_action; static void ScreenSizeCallback( void *s ) { - menuslider_s *slider = ( menuslider_s * ) s; - + menuslider_s *slider = (menuslider_s *)s; Cvar_SetValue( "viewsize", slider->curvalue * 10 ); } static void BrightnessCallback( void *s ) { - menuslider_s *slider = ( menuslider_s * ) s; + menuslider_s *slider = (menuslider_s *)s; + float gamma = ( 0.8 - ( slider->curvalue / 10.0 - 0.5 ) ) + 0.5; - if ( s_current_menu_index == SOFTWARE_MENU ) - s_brightness_slider[1].curvalue = s_brightness_slider[0].curvalue; - else - s_brightness_slider[0].curvalue = s_brightness_slider[1].curvalue; - - if ( stricmp( vid_ref->string, "soft" ) == 0 ) - { - float gamma = ( 0.8 - ( slider->curvalue/10.0 - 0.5 ) ) + 0.5; - - Cvar_SetValue( "vid_gamma", gamma ); - } + Cvar_SetValue( "vid_gamma", gamma ); } static void ResetDefaults( void *unused ) @@ -117,81 +72,14 @@ static void ResetDefaults( void *unused ) static void ApplyChanges( void *unused ) { - float gamma; + extern cvar_t *vid_ref; - /* - ** make values consistent - */ - s_fs_box[!s_current_menu_index].curvalue = s_fs_box[s_current_menu_index].curvalue; - s_brightness_slider[!s_current_menu_index].curvalue = s_brightness_slider[s_current_menu_index].curvalue; - s_ref_list[!s_current_menu_index].curvalue = s_ref_list[s_current_menu_index].curvalue; - - /* - ** invert sense so greater = brighter, and scale to a range of 0.5 to 1.3 - */ - gamma = ( 0.8 - ( s_brightness_slider[s_current_menu_index].curvalue/10.0 - 0.5 ) ) + 0.5; - - Cvar_SetValue( "vid_gamma", gamma ); - Cvar_SetValue( "sw_stipplealpha", s_stipple_box.curvalue ); Cvar_SetValue( "gl_picmip", 3 - s_tq_slider.curvalue ); - Cvar_SetValue( "vid_fullscreen", s_fs_box[s_current_menu_index].curvalue ); + Cvar_SetValue( "vid_fullscreen", s_fs_box.curvalue ); Cvar_SetValue( "gl_ext_palettedtexture", s_paletted_texture_box.curvalue ); Cvar_SetValue( "gl_finish", s_finish_box.curvalue ); - Cvar_SetValue( "sw_mode", s_mode_list[SOFTWARE_MENU].curvalue ); - Cvar_SetValue( "gl_mode", s_mode_list[OPENGL_MENU].curvalue ); - - switch ( s_ref_list[s_current_menu_index].curvalue ) - { - case REF_SOFT: - Cvar_Set( "vid_ref", "soft" ); - break; - case REF_OPENGL: - Cvar_Set( "vid_ref", "gl" ); - Cvar_Set( "gl_driver", "opengl32" ); - break; - case REF_3DFX: - Cvar_Set( "vid_ref", "gl" ); - Cvar_Set( "gl_driver", "3dfxgl" ); - break; - case REF_POWERVR: - Cvar_Set( "vid_ref", "gl" ); - Cvar_Set( "gl_driver", "pvrgl" ); - break; - case REF_VERITE: - Cvar_Set( "vid_ref", "gl" ); - Cvar_Set( "gl_driver", "veritegl" ); - break; - } - - /* - ** update appropriate stuff if we're running OpenGL and gamma - ** has been modified - */ - if ( stricmp( vid_ref->string, "gl" ) == 0 ) - { - if ( vid_gamma->modified ) - { - vid_ref->modified = true; - if ( stricmp( gl_driver->string, "3dfxgl" ) == 0 ) - { - char envbuffer[1024]; - float g; - - vid_ref->modified = true; - - g = 2.00 * ( 0.8 - ( vid_gamma->value - 0.5 ) ) + 1.0F; - sprintf( envbuffer, "SSTV2_GAMMA=%f", g ); - putenv( envbuffer ); - sprintf( envbuffer, "SST_GAMMA=%f", g ); - putenv( envbuffer ); - - vid_gamma->modified = false; - } - } - - if ( gl_driver->modified ) - vid_ref->modified = true; - } + Cvar_SetValue( "gl_mode", s_mode_list.curvalue ); + vid_ref->modified = true; M_ForceMenuOff(); } @@ -211,190 +99,111 @@ void VID_MenuInit( void ) static const char *resolutions[] = { "[320 240 ]", - "[400 300 ]", - "[512 384 ]", "[640 480 ]", "[800 600 ]", - "[960 720 ]", "[1024 768 ]", - "[1152 864 ]", "[1280 960 ]", + "[1280 1024]", "[1600 1200]", "[2048 1536]", - 0 - }; - static const char *refs[] = - { - "[software ]", - "[default OpenGL]", - "[3Dfx OpenGL ]", - "[PowerVR OpenGL]", -// "[Rendition OpenGL]", - 0 + 0, }; static const char *yesno_names[] = { "no", "yes", - 0 + 0, }; - int i; - if ( !gl_driver ) - gl_driver = Cvar_Get( "gl_driver", "opengl32", 0 ); - if ( !gl_picmip ) - gl_picmip = Cvar_Get( "gl_picmip", "0", 0 ); - if ( !gl_mode ) - gl_mode = Cvar_Get( "gl_mode", "3", 0 ); - if ( !sw_mode ) - sw_mode = Cvar_Get( "sw_mode", "0", 0 ); - if ( !gl_ext_palettedtexture ) - gl_ext_palettedtexture = Cvar_Get( "gl_ext_palettedtexture", "1", CVAR_ARCHIVE ); - if ( !gl_finish ) - gl_finish = Cvar_Get( "gl_finish", "0", CVAR_ARCHIVE ); + if ( !gl_picmip ) gl_picmip = Cvar_Get( "gl_picmip", "0", 0 ); + if ( !gl_mode ) gl_mode = Cvar_Get( "gl_mode", "3", 0 ); + if ( !gl_finish ) gl_finish = Cvar_Get( "gl_finish", "0", CVAR_ARCHIVE ); + if ( !scr_viewsize ) scr_viewsize = Cvar_Get ("viewsize", "100", CVAR_ARCHIVE); + if ( !gl_ext_palettedtexture ) gl_ext_palettedtexture = Cvar_Get( "gl_ext_palettedtexture", "1", CVAR_ARCHIVE ); - if ( !sw_stipplealpha ) - sw_stipplealpha = Cvar_Get( "sw_stipplealpha", "0", CVAR_ARCHIVE ); + s_mode_list.curvalue = gl_mode->value; + s_screensize_slider.curvalue = scr_viewsize->value/10; - s_mode_list[SOFTWARE_MENU].curvalue = sw_mode->value; - s_mode_list[OPENGL_MENU].curvalue = gl_mode->value; + s_video_menu.x = viddef.width * 0.50; + s_video_menu.y = viddef.height / 2 - 58; + s_video_menu.nitems = 0; - if ( !scr_viewsize ) - scr_viewsize = Cvar_Get ("viewsize", "100", CVAR_ARCHIVE); + s_mode_list.generic.type = MTYPE_SPINCONTROL; + s_mode_list.generic.name = "video mode"; + s_mode_list.generic.x = 0; + s_mode_list.generic.y = 0; + s_mode_list.itemnames = resolutions; - s_screensize_slider[SOFTWARE_MENU].curvalue = scr_viewsize->value/10; - s_screensize_slider[OPENGL_MENU].curvalue = scr_viewsize->value/10; + s_screensize_slider.generic.type = MTYPE_SLIDER; + s_screensize_slider.generic.x = 0; + s_screensize_slider.generic.y = 10; + s_screensize_slider.generic.name = "screen size"; + s_screensize_slider.minvalue = 3; + s_screensize_slider.maxvalue = 12; + s_screensize_slider.generic.callback = ScreenSizeCallback; - if ( strcmp( vid_ref->string, "soft" ) == 0 ) - { - s_current_menu_index = SOFTWARE_MENU; - s_ref_list[0].curvalue = s_ref_list[1].curvalue = REF_SOFT; - } - else if ( strcmp( vid_ref->string, "gl" ) == 0 ) - { - s_current_menu_index = OPENGL_MENU; - if ( strcmp( gl_driver->string, "3dfxgl" ) == 0 ) - s_ref_list[s_current_menu_index].curvalue = REF_3DFX; - else if ( strcmp( gl_driver->string, "pvrgl" ) == 0 ) - s_ref_list[s_current_menu_index].curvalue = REF_POWERVR; - else if ( strcmp( gl_driver->string, "opengl32" ) == 0 ) - s_ref_list[s_current_menu_index].curvalue = REF_OPENGL; - else -// s_ref_list[s_current_menu_index].curvalue = REF_VERITE; - s_ref_list[s_current_menu_index].curvalue = REF_OPENGL; - } + s_brightness_slider.generic.type = MTYPE_SLIDER; + s_brightness_slider.generic.x = 0; + s_brightness_slider.generic.y = 20; + s_brightness_slider.generic.name = "brightness"; + s_brightness_slider.generic.callback = BrightnessCallback; + s_brightness_slider.minvalue = 5; + s_brightness_slider.maxvalue = 13; + s_brightness_slider.curvalue = ( 1.3 - vid_gamma->value + 0.5 ) * 10; - s_software_menu.x = viddef.width * 0.50; - s_software_menu.nitems = 0; - s_opengl_menu.x = viddef.width * 0.50; - s_opengl_menu.nitems = 0; + s_fs_box.generic.type = MTYPE_SPINCONTROL; + s_fs_box.generic.x = 0; + s_fs_box.generic.y = 30; + s_fs_box.generic.name = "fullscreen"; + s_fs_box.itemnames = yesno_names; + s_fs_box.curvalue = vid_fullscreen->value; - for ( i = 0; i < 2; i++ ) - { - s_ref_list[i].generic.type = MTYPE_SPINCONTROL; - s_ref_list[i].generic.name = "driver"; - s_ref_list[i].generic.x = 0; - s_ref_list[i].generic.y = 0; - s_ref_list[i].generic.callback = DriverCallback; - s_ref_list[i].itemnames = refs; - - s_mode_list[i].generic.type = MTYPE_SPINCONTROL; - s_mode_list[i].generic.name = "video mode"; - s_mode_list[i].generic.x = 0; - s_mode_list[i].generic.y = 10; - s_mode_list[i].itemnames = resolutions; - - s_screensize_slider[i].generic.type = MTYPE_SLIDER; - s_screensize_slider[i].generic.x = 0; - s_screensize_slider[i].generic.y = 20; - s_screensize_slider[i].generic.name = "screen size"; - s_screensize_slider[i].minvalue = 3; - s_screensize_slider[i].maxvalue = 12; - s_screensize_slider[i].generic.callback = ScreenSizeCallback; - - s_brightness_slider[i].generic.type = MTYPE_SLIDER; - s_brightness_slider[i].generic.x = 0; - s_brightness_slider[i].generic.y = 30; - s_brightness_slider[i].generic.name = "brightness"; - s_brightness_slider[i].generic.callback = BrightnessCallback; - s_brightness_slider[i].minvalue = 5; - s_brightness_slider[i].maxvalue = 13; - s_brightness_slider[i].curvalue = ( 1.3 - vid_gamma->value + 0.5 ) * 10; - - s_fs_box[i].generic.type = MTYPE_SPINCONTROL; - s_fs_box[i].generic.x = 0; - s_fs_box[i].generic.y = 40; - s_fs_box[i].generic.name = "fullscreen"; - s_fs_box[i].itemnames = yesno_names; - s_fs_box[i].curvalue = vid_fullscreen->value; - - s_defaults_action[i].generic.type = MTYPE_ACTION; - s_defaults_action[i].generic.name = "reset to defaults"; - s_defaults_action[i].generic.x = 0; - s_defaults_action[i].generic.y = 90; - s_defaults_action[i].generic.callback = ResetDefaults; - - s_cancel_action[i].generic.type = MTYPE_ACTION; - s_cancel_action[i].generic.name = "cancel"; - s_cancel_action[i].generic.x = 0; - s_cancel_action[i].generic.y = 100; - s_cancel_action[i].generic.callback = CancelChanges; - } - - s_stipple_box.generic.type = MTYPE_SPINCONTROL; - s_stipple_box.generic.x = 0; - s_stipple_box.generic.y = 60; - s_stipple_box.generic.name = "stipple alpha"; - s_stipple_box.curvalue = sw_stipplealpha->value; - s_stipple_box.itemnames = yesno_names; - - s_tq_slider.generic.type = MTYPE_SLIDER; - s_tq_slider.generic.x = 0; - s_tq_slider.generic.y = 60; - s_tq_slider.generic.name = "texture quality"; + s_tq_slider.generic.type = MTYPE_SLIDER; + s_tq_slider.generic.x = 0; + s_tq_slider.generic.y = 40; + s_tq_slider.generic.name = "texture quality"; s_tq_slider.minvalue = 0; s_tq_slider.maxvalue = 3; - s_tq_slider.curvalue = 3-gl_picmip->value; + s_tq_slider.curvalue = 3 - gl_picmip->value; s_paletted_texture_box.generic.type = MTYPE_SPINCONTROL; - s_paletted_texture_box.generic.x = 0; - s_paletted_texture_box.generic.y = 70; - s_paletted_texture_box.generic.name = "8-bit textures"; + s_paletted_texture_box.generic.x = 0; + s_paletted_texture_box.generic.y = 50; + s_paletted_texture_box.generic.name = "8-bit textures"; s_paletted_texture_box.itemnames = yesno_names; s_paletted_texture_box.curvalue = gl_ext_palettedtexture->value; s_finish_box.generic.type = MTYPE_SPINCONTROL; - s_finish_box.generic.x = 0; - s_finish_box.generic.y = 80; - s_finish_box.generic.name = "sync every frame"; + s_finish_box.generic.x = 0; + s_finish_box.generic.y = 60; + s_finish_box.generic.name = "sync every frame"; s_finish_box.curvalue = gl_finish->value; s_finish_box.itemnames = yesno_names; - Menu_AddItem( &s_software_menu, ( void * ) &s_ref_list[SOFTWARE_MENU] ); - Menu_AddItem( &s_software_menu, ( void * ) &s_mode_list[SOFTWARE_MENU] ); - Menu_AddItem( &s_software_menu, ( void * ) &s_screensize_slider[SOFTWARE_MENU] ); - Menu_AddItem( &s_software_menu, ( void * ) &s_brightness_slider[SOFTWARE_MENU] ); - Menu_AddItem( &s_software_menu, ( void * ) &s_fs_box[SOFTWARE_MENU] ); - Menu_AddItem( &s_software_menu, ( void * ) &s_stipple_box ); + s_defaults_action.generic.type = MTYPE_ACTION; + s_defaults_action.generic.name = "reset to defaults"; + s_defaults_action.generic.x = 0; + s_defaults_action.generic.y = 80; + s_defaults_action.generic.callback = ResetDefaults; - Menu_AddItem( &s_opengl_menu, ( void * ) &s_ref_list[OPENGL_MENU] ); - Menu_AddItem( &s_opengl_menu, ( void * ) &s_mode_list[OPENGL_MENU] ); - Menu_AddItem( &s_opengl_menu, ( void * ) &s_screensize_slider[OPENGL_MENU] ); - Menu_AddItem( &s_opengl_menu, ( void * ) &s_brightness_slider[OPENGL_MENU] ); - Menu_AddItem( &s_opengl_menu, ( void * ) &s_fs_box[OPENGL_MENU] ); - Menu_AddItem( &s_opengl_menu, ( void * ) &s_tq_slider ); - Menu_AddItem( &s_opengl_menu, ( void * ) &s_paletted_texture_box ); - Menu_AddItem( &s_opengl_menu, ( void * ) &s_finish_box ); + s_cancel_action.generic.type = MTYPE_ACTION; + s_cancel_action.generic.name = "cancel"; + s_cancel_action.generic.x = 0; + s_cancel_action.generic.y = 90; + s_cancel_action.generic.callback = CancelChanges; - Menu_AddItem( &s_software_menu, ( void * ) &s_defaults_action[SOFTWARE_MENU] ); - Menu_AddItem( &s_software_menu, ( void * ) &s_cancel_action[SOFTWARE_MENU] ); - Menu_AddItem( &s_opengl_menu, ( void * ) &s_defaults_action[OPENGL_MENU] ); - Menu_AddItem( &s_opengl_menu, ( void * ) &s_cancel_action[OPENGL_MENU] ); + Menu_AddItem( &s_video_menu, ( void * ) &s_mode_list ); + Menu_AddItem( &s_video_menu, ( void * ) &s_screensize_slider ); + Menu_AddItem( &s_video_menu, ( void * ) &s_brightness_slider ); + Menu_AddItem( &s_video_menu, ( void * ) &s_fs_box ); + Menu_AddItem( &s_video_menu, ( void * ) &s_tq_slider ); + Menu_AddItem( &s_video_menu, ( void * ) &s_paletted_texture_box ); + Menu_AddItem( &s_video_menu, ( void * ) &s_finish_box ); + Menu_AddItem( &s_video_menu, ( void * ) &s_defaults_action ); + Menu_AddItem( &s_video_menu, ( void * ) &s_cancel_action ); - Menu_Center( &s_software_menu ); - Menu_Center( &s_opengl_menu ); - s_opengl_menu.x -= 8; - s_software_menu.x -= 8; + Menu_Center( &s_video_menu ); + s_video_menu.x -= 8; } /* @@ -406,26 +215,15 @@ void VID_MenuDraw (void) { int w, h; - if ( s_current_menu_index == 0 ) - s_current_menu = &s_software_menu; - else - s_current_menu = &s_opengl_menu; - - /* - ** draw the banner - */ + // draw the banner re->DrawGetPicSize( &w, &h, "m_banner_video" ); re->DrawPic( viddef.width / 2 - w / 2, viddef.height /2 - 110, "m_banner_video" ); - /* - ** move cursor to a reasonable starting position - */ - Menu_AdjustCursor( s_current_menu, 1 ); + // move cursor to a reasonable starting position + Menu_AdjustCursor( &s_video_menu, 1 ); - /* - ** draw the menu - */ - Menu_Draw( s_current_menu ); + // draw the menu + Menu_Draw( &s_video_menu ); } /* @@ -435,7 +233,7 @@ VID_MenuKey */ const char *VID_MenuKey( int key ) { - menuframework_s *m = s_current_menu; + menuframework_s *m = &s_video_menu; static const char *sound = "misc/menu1.wav"; switch ( key ) diff --git a/launcher/console.c b/launcher/console.c index 55931a33..8b011429 100644 --- a/launcher/console.c +++ b/launcher/console.c @@ -7,6 +7,7 @@ HINSTANCE base_hInstance; FILE *logfile; +char log_path[256]; /* =============================================================================== @@ -231,7 +232,7 @@ void Sys_PrintW(const char *pMsg) { if (!logfile) { - logfile = fopen ("engine.log", "w"); + logfile = fopen ( log_path, "w"); fprintf (logfile, "=======================================================================\n" ); fprintf (logfile, "\t\tXash3D started at %s\n", Log_Timestamp()); fprintf (logfile, "=======================================================================\n"); diff --git a/launcher/launcher.c b/launcher/launcher.c index d95521f2..42b06a62 100644 --- a/launcher/launcher.c +++ b/launcher/launcher.c @@ -63,12 +63,14 @@ void LookupInstance( const char *funcname ) //don't show console as default if(!debug_mode) show_always = false; strcpy(dllname, "bin/engine.dll" ); + strcpy(log_path, "engine.log" ); // xash3d root directory } else if(!strcmp(progname, "host_dedicated")) { app_name = HOST_DEDICATED; console_read_only = false; strcpy(dllname, "bin/engine.dll" ); + strcpy(log_path, "engine.log" ); // xash3d root directory } else if(!strcmp(progname, "host_editor")) { @@ -77,21 +79,25 @@ void LookupInstance( const char *funcname ) //don't show console as default if(!debug_mode) show_always = false; strcpy(dllname, "bin/editor.dll" ); + strcpy(log_path, "editor.log" ); // xash3d root directory } else if(!strcmp(progname, "bsplib")) { app_name = BSPLIB; strcpy(dllname, "bin/platform.dll" ); + strcpy(log_path, "bsplib.log" ); // xash3d root directory } else if(!strcmp(progname, "sprite")) { app_name = SPRITE; strcpy(dllname, "bin/platform.dll" ); + sprintf(log_path, "%s/spritegen.log", sys_rootdir ); // same as .exe file } else if(!strcmp(progname, "studio")) { app_name = STUDIO; strcpy(dllname, "bin/platform.dll" ); + sprintf(log_path, "%s/studiomdl.log", sys_rootdir ); // same as .exe file } else if(!strcmp(progname, "credits")) //easter egg { @@ -339,6 +345,8 @@ void InitLauncher( char *funcname ) if(CheckParm ("-log")) log_active = true; if(abs((short)hStdout) < 100) hooked_out = false; else hooked_out = true; + + UpdateEnvironmentVariables(); // set working directory //init launcher LookupInstance( funcname ); @@ -346,9 +354,6 @@ void InitLauncher( char *funcname ) API_SetConsole(); //initialize system console Sys_InitConsole(); - // set working directory - UpdateEnvironmentVariables(); - // first text message into console or log Msg("------- Loading bin/launcher.dll [%g] -------\n", LAUNCHER_VERSION ); CreateInstance(); diff --git a/launcher/launcher.h b/launcher/launcher.h index 00b75a8b..88e4af2d 100644 --- a/launcher/launcher.h +++ b/launcher/launcher.h @@ -36,6 +36,8 @@ extern bool debug_mode; extern bool log_active; extern int com_argc; extern char *com_argv[MAX_NUM_ARGVS]; +extern char sys_rootdir[ MAX_SYSPATH ]; +extern char log_path[256]; extern bool console_read_only; extern bool show_always; char *va(const char *format, ...); diff --git a/platform/baseutils.c b/platform/baseutils.c index e51e1a77..ef646a68 100644 --- a/platform/baseutils.c +++ b/platform/baseutils.c @@ -97,7 +97,7 @@ bool AddScriptToStack(const char *name, byte *buffer, int size) { if (script == &scriptstack[MAX_INCLUDES - 1]) { - Msg("script file exceeded limit %d", MAX_INCLUDES ); + MsgWarn("AddScriptToStack: script file limit exceeded %d\n", MAX_INCLUDES ); return false; } if(!buffer || !size) return false; @@ -105,7 +105,7 @@ bool AddScriptToStack(const char *name, byte *buffer, int size) script++; strcpy (script->filename, name ); script->buffer = buffer; - script->line = 1; + script->line = scriptline = 1; script->script_p = script->buffer; script->end_p = script->buffer + size; @@ -121,7 +121,6 @@ bool FS_LoadScript( const char *filename, char *buf, int size ) script = scriptstack; result = AddScriptToStack( filename, buf, size); - if(result)MsgDev("Load script %s\n", filename ); endofscript = false; tokenready = false; @@ -130,15 +129,9 @@ bool FS_LoadScript( const char *filename, char *buf, int size ) bool FS_AddScript( const char *filename, char *buf, int size ) { - int result; - - if(!buf || size <= 0) + if(!buf || size <= 0) buf = FS_LoadFile (filename, &size ); - - result = AddScriptToStack(filename, buf, size); - if(result) MsgDev("Insert script %s\n", filename ); - - return result; + return AddScriptToStack(filename, buf, size); } /* @@ -165,6 +158,7 @@ skip_whitespace: // skip whitespace { if (script->script_p >= script->end_p) return EndOfScript (newline); + if (*script->script_p++ == '\n') { if (!newline) goto line_incomplete; @@ -180,13 +174,15 @@ skip_whitespace: // skip whitespace { if (!newline) goto line_incomplete; - //ets+++ + // ets+++ if (*script->script_p == '/') script->script_p++; if (script->script_p[1] == 'T' && script->script_p[2] == 'X') g_TXcommand = script->script_p[3];//TX#"-style comment while (*script->script_p++ != '\n') + { if (script->script_p >= script->end_p) return EndOfScript (newline); + } goto skip_whitespace; } @@ -194,12 +190,17 @@ skip_whitespace: // skip whitespace if (script->script_p[0] == '/' && script->script_p[1] == '*') { if (!newline) goto line_incomplete; - script->script_p+=2; + + script->script_p += 2; while (script->script_p[0] != '*' && script->script_p[1] != '/') { - script->script_p++; if (script->script_p >= script->end_p) return EndOfScript (newline); + if (*script->script_p++ == '\n') + { + if (!newline) goto line_incomplete; + scriptline = script->line++; + } } script->script_p += 2; goto skip_whitespace; @@ -216,7 +217,7 @@ skip_whitespace: // skip whitespace { if (token_p == &token[MAX_SYSPATH - 1]) { - Msg("GetToken: Token too large on line %i\n", scriptline); + MsgWarn("GetToken: Token too large on line %i\n", scriptline); break; } @@ -232,7 +233,7 @@ skip_whitespace: // skip whitespace { if (token_p == &token[MAX_SYSPATH - 1]) { - Msg("GetToken: Token too large on line %i\n",scriptline); + MsgWarn("GetToken: Token too large on line %i\n",scriptline); break; } @@ -254,7 +255,6 @@ skip_whitespace: // skip whitespace return true; line_incomplete: - //invoke error return EndOfScript( newline ); } @@ -266,8 +266,11 @@ EndOfScript */ bool EndOfScript (bool newline) { - if (!newline) Sys_Error ("Line %i is incomplete\n", scriptline); - + if (!newline) + { + scriptline = script->line; + Sys_Error ("%s: line %i is incomplete\n", script->filename, scriptline); + } if (!strcmp (script->filename, "script buffer")) { endofscript = true; @@ -284,8 +287,6 @@ bool EndOfScript (bool newline) scriptline = script->line; endofscript = true; - MsgDev("returning to %s\n", script->filename); - return false; } @@ -325,100 +326,6 @@ SC_ParseToken Parse a token out of a string ============== */ - -#if 0 -char *SC_ParseToken(const char **data_p) -{ - int c, len; - const char *data; - - data = *data_p; - len = 0; - token[0] = 0; - - if (!data) - { - *data_p = NULL; - return NULL; - } - -// skip whitespace -skipwhite: - while ( (c = *data) <= ' ') - { - if (c == 0) - { - endofscript = true; - *data_p = NULL; - return NULL; // end of file; - } - data++; - } - - // skip // comments - if (c=='/' && data[1] == '/') - { - while (*data && *data != '\n') - data++; - goto skipwhite; - } - - // skip /* comments - if (c=='/' && data[1] == '*') - { - while (data[1] && (data[0] != '*' || data[1] != '/')) - data++; - data += 2; - goto skipwhite; - } - - - // handle quoted strings specially - if (c == '\"') - { - data++; - while( 1 ) - { - c = *data++; - if (c=='\"'|| c== '\0') - { - token[len] = 0; - *data_p = data; - return token; - } - token[len] = c; - len++; - } - } - - // parse single characters - if (c == '{' || c == '}'|| c == ')' || c == '(' || c == '\'' || c == ':' || c == ',') - { - token[len] = c; - len++; - token[len] = 0; - *data_p = data; - return token + 1; - } - - // parse a regular word - do - { - token[len] = c; - data++; - len++; - c = *data; - if (c == '{' || c == '}'|| c == ')'|| c == '(' || c == '\'' || c == ':' || c == '\"' || c == ',') - break; - } while(c > 32); - - token[len] = 0; - *data_p = data; - return token; -} - -#else - char *SC_ParseToken(const char **data_p) { int c; @@ -435,8 +342,8 @@ char *SC_ParseToken(const char **data_p) return NULL; } -// skip whitespace -skipwhite: + +skipwhite: // skip whitespace while ( (c = *data) <= ' ') { if (c == 0) @@ -447,7 +354,7 @@ skipwhite: data++; } -// skip // comments + // skip // comments if (c=='/' && data[1] == '/') { while (*data && *data != '\n') @@ -455,7 +362,7 @@ skipwhite: goto skipwhite; } -// handle quoted strings specially + // handle quoted strings specially if (c == '\"') { data++; @@ -476,7 +383,7 @@ skipwhite: } } -// parse a regular word + // parse a regular word do { if (len < MAX_OSPATH) @@ -488,17 +395,12 @@ skipwhite: c = *data; } while (c > 32); - if (len == MAX_OSPATH) - { -// Msg ("Token exceeded %i chars, discarded.\n", MAX_TOKEN_CHARS); - len = 0; - } + if (len == MAX_OSPATH) len = 0; token[len] = 0; *data_p = data; return token; } -#endif /* ============================================================================= @@ -1130,16 +1032,15 @@ used for make sprites and models (old stuff) ================ */ - byte *ReadBMP (char *filename, byte **palette, int *width, int *height) { - byte *buf_p, *pbBmpBits; - byte *buf, *pb, *pbPal = NULL; - int i, filesize, columns, rows; - ULONG cbBmpBits; - ULONG cbPalBytes; - ULONG biTrueWidth; - bmp_t bhdr; + byte *buf_p, *pbBmpBits; + byte *buf, *pb, *pbPal = NULL; + int i, filesize, columns, rows; + dword cbBmpBits; + dword cbPalBytes; + dword biTrueWidth; + bmp_t bhdr; RGBQUAD rgrgbPalette[256]; @@ -1150,7 +1051,7 @@ byte *ReadBMP (char *filename, byte **palette, int *width, int *height) //blank_frame buf_p = (char *)blank_frame; filesize = sizeof(blank_frame); - Msg("Warning: couldn't load %s\n", filename ); + MsgWarn("ReadBMP: couldn't load %s, use blank image\n", filename ); } bhdr.id[0] = *buf_p++; @@ -1176,21 +1077,21 @@ byte *ReadBMP (char *filename, byte **palette, int *width, int *height) if (memcmp(bhdr.id, "BM", 2)) { - Msg("ReadBMP: only Windows-style BMP files supported (%s)\n", filename ); + MsgWarn("ReadBMP: only Windows-style BMP files supported (%s)\n", filename ); return NULL; } // Bogus info header check if (bhdr.fileSize != filesize) { - Msg("ReadBMP: incorrect file size %i should be %i\n", filesize, bhdr.fileSize); + MsgWarn("ReadBMP: incorrect file size %i should be %i\n", filesize, bhdr.fileSize); return NULL; } // Bogus bit depth? Only 8-bit supported. if (bhdr.bitsPerPixel != 8) { - Msg("ReadBMP: %d not a 8 bit image\n", bhdr.bitsPerPixel ); + MsgWarn("ReadBMP: %d not a 8 bit image\n", bhdr.bitsPerPixel ); return NULL; } @@ -1281,15 +1182,23 @@ static int enter; void ThreadLock (void) { if (!threaded) return; + if (enter) + { + MsgWarn("ThreadLock: recursive call\n"); + return; + } EnterCriticalSection (&crit); - if (enter) Sys_Error ("Recursive ThreadLock\n"); enter = 1; } void ThreadUnlock (void) { if (!threaded) return; - if (!enter) Sys_Error ("ThreadUnlock without lock\n"); + if (!enter) + { + MsgWarn("ThreadUnlock: must call ThreadLock first\n"); + return; + } enter = 0; LeaveCriticalSection (&crit); } @@ -1327,7 +1236,7 @@ void ThreadWorkerFunction (int threadnum) while (1) { - work = GetThreadWork (); + work = GetThreadWork(); if (work == -1) break; workfunction(work); } @@ -1342,7 +1251,7 @@ void ThreadSetDefault (void) if (numthreads < 1 || numthreads > MAX_THREADS) numthreads = 1; } - MsgDev("%i thread%s\n", numthreads, numthreads== 1 ? "" : "s" ); + MsgDev("%i thread%s\n", numthreads, numthreads == 1 ? "" : "s" ); } void RunThreadsOnIndividual (int workcnt, bool showpacifier, void(*func)(int)) diff --git a/platform/baseutils.h b/platform/baseutils.h index cdd95125..a6ffd0db 100644 --- a/platform/baseutils.h +++ b/platform/baseutils.h @@ -111,7 +111,7 @@ extern char gs_mapname[ 64 ]; extern char gs_basedir[ MAX_SYSPATH ]; extern char g_TXcommand; extern bool endofscript; - +extern bool host_debug; extern int fs_argc; extern char **fs_argv; diff --git a/platform/bsplib/bspfile.c b/platform/bsplib/bspfile.c index 2b397bd9..29f09bbf 100644 --- a/platform/bsplib/bspfile.c +++ b/platform/bsplib/bspfile.c @@ -495,11 +495,11 @@ epair_t *ParseEpair (void) e = Malloc (sizeof(epair_t)); - if (strlen(token) >= MAX_KEY - 1) Sys_Error ("ParseEpar: token too long"); - e->key = copystring(token); + if (strlen(SC_Token()) >= MAX_KEY - 1) Sys_Error ("ParseEpar: token too long"); + e->key = copystring(SC_Token()); SC_GetToken (false); - if (strlen(token) >= MAX_VALUE - 1) Sys_Error ("ParseEpar: token too long"); - e->value = copystring(token); + if (strlen(SC_Token()) >= MAX_VALUE - 1) Sys_Error ("ParseEpar: token too long"); + e->value = copystring(SC_Token()); // strip trailing spaces StripTrailing (e->key); diff --git a/platform/bsplib/map.c b/platform/bsplib/map.c index f5092e3f..dc549f56 100644 --- a/platform/bsplib/map.c +++ b/platform/bsplib/map.c @@ -559,7 +559,7 @@ void ParseBrush (bsp_entity_t *mapent) for (j=0 ; j<3 ; j++) { SC_GetToken (false); - planepts[i][j] = atof(token); + planepts[i][j] = atof(SC_Token()); } SC_GetToken (false); @@ -568,37 +568,37 @@ void ParseBrush (bsp_entity_t *mapent) // read the texturedef SC_GetToken (false); - strcpy (td.name, token); + strcpy (td.name, SC_Token()); if(g_mapversion == VALVE_FORMAT) // Worldcraft 2.2+ { // texture U axis SC_GetToken(false); - if (strcmp(token, "[")) Sys_Error("missing '[' in texturedef (U)"); + if (strcmp(SC_Token(), "[")) Sys_Error("missing '[' in texturedef (U)"); SC_GetToken(false); - td.vects.valve.UAxis[0] = atof(token); + td.vects.valve.UAxis[0] = atof(SC_Token()); SC_GetToken(false); - td.vects.valve.UAxis[1] = atof(token); + td.vects.valve.UAxis[1] = atof(SC_Token()); SC_GetToken(false); - td.vects.valve.UAxis[2] = atof(token); + td.vects.valve.UAxis[2] = atof(SC_Token()); SC_GetToken(false); - td.vects.valve.shift[0] = atof(token); + td.vects.valve.shift[0] = atof(SC_Token()); SC_GetToken(false); - if (strcmp(token, "]")) Sys_Error("missing ']' in texturedef (U)"); + if (strcmp(SC_Token(), "]")) Sys_Error("missing ']' in texturedef (U)"); // texture V axis SC_GetToken(false); - if (strcmp(token, "[")) Sys_Error("missing '[' in texturedef (V)"); + if (strcmp(SC_Token(), "[")) Sys_Error("missing '[' in texturedef (V)"); SC_GetToken(false); - td.vects.valve.VAxis[0] = atof(token); + td.vects.valve.VAxis[0] = atof(SC_Token()); SC_GetToken(false); - td.vects.valve.VAxis[1] = atof(token); + td.vects.valve.VAxis[1] = atof(SC_Token()); SC_GetToken(false); - td.vects.valve.VAxis[2] = atof(token); + td.vects.valve.VAxis[2] = atof(SC_Token()); SC_GetToken(false); - td.vects.valve.shift[1] = atof(token); + td.vects.valve.shift[1] = atof(SC_Token()); SC_GetToken(false); - if (strcmp(token, "]")) Sys_Error("missing ']' in texturedef (V)"); + if (strcmp(SC_Token(), "]")) Sys_Error("missing ']' in texturedef (V)"); // Texture rotation is implicit in U/V axes. SC_GetToken(false); @@ -606,23 +606,23 @@ void ParseBrush (bsp_entity_t *mapent) // texure scale SC_GetToken(false); - td.vects.valve.scale[0] = atof(token); + td.vects.valve.scale[0] = atof(SC_Token()); SC_GetToken(false); - td.vects.valve.scale[1] = atof(token); + td.vects.valve.scale[1] = atof(SC_Token()); } else { // Worldcraft 2.1-, Radiant SC_GetToken (false); - td.vects.valve.shift[0] = atof(token); + td.vects.valve.shift[0] = atof(SC_Token()); SC_GetToken (false); - td.vects.valve.shift[1] = atof(token); + td.vects.valve.shift[1] = atof(SC_Token()); SC_GetToken (false); - td.vects.valve.rotate = atof(token); + td.vects.valve.rotate = atof(SC_Token()); SC_GetToken (false); - td.vects.valve.scale[0] = atof(token); + td.vects.valve.scale[0] = atof(SC_Token()); SC_GetToken (false); - td.vects.valve.scale[1] = atof(token); + td.vects.valve.scale[1] = atof(SC_Token()); } if ((g_TXcommand == '1' || g_TXcommand == '2')) @@ -680,13 +680,13 @@ void ParseBrush (bsp_entity_t *mapent) //Msg("flags %d, value %d, contents %d\n", td.flags, td.value, side->contents ); - if (SC_TryToken()) //first token will be get automatically + if (SC_TryToken()) //first SC_Token() will be get automatically { - side->contents = atoi(token); + side->contents = atoi(SC_Token()); SC_GetToken (false); - side->surf = td.flags = atoi(token); + side->surf = td.flags = atoi(SC_Token()); SC_GetToken (false); - td.value = atoi(token); + td.value = atoi(SC_Token()); } // translucent objects are automatically classified as detail diff --git a/platform/bsplib/qrad3.c b/platform/bsplib/qrad3.c index 1e67f757..aad26d14 100644 --- a/platform/bsplib/qrad3.c +++ b/platform/bsplib/qrad3.c @@ -27,7 +27,7 @@ char inbase[32], outbase[32]; int fakeplanes; // created planes for origin offset -int numbounce = 8; +int numbounce; bool extrasamples; float subdiv = 64; @@ -382,7 +382,7 @@ void BounceLight (void) } } - for (i=0 ; iname, token ); + strcpy( si->name, SC_Token() ); SC_GetToken( true ); if(!SC_MatchToken( "{" )) @@ -141,31 +141,31 @@ static void ParseShaderFile( char *filename ) while ( 1 ) { if ( !SC_GetToken( true ) )break; - if ( !strcmp( token, "}" ) ) break; + if ( !strcmp( SC_Token(), "}" ) ) break; // skip internal braced sections - if ( !strcmp( token, "{" ) ) + if ( !strcmp( SC_Token(), "{" ) ) { si->hasPasses = true; while ( 1 ) { if ( !SC_GetToken( true )) break; - if ( !strcmp( token, "}" )) break; + if ( !strcmp( SC_Token(), "}" )) break; } continue; } - if ( !stricmp( token, "nextframe" )) + if ( !stricmp( SC_Token(), "nextframe" )) { SC_GetToken( false ); - strcpy(si->nextframe, token ); + strcpy(si->nextframe, SC_Token() ); } - if ( !stricmp( token, "surfaceparm" )) + if ( !stricmp( SC_Token(), "surfaceparm" )) { SC_GetToken( false ); for ( i = 0 ; i < numInfoParms ; i++ ) { - if ( !stricmp( token, infoParms[i].name )) + if ( !stricmp( SC_Token(), infoParms[i].name )) { si->surfaceFlags |= infoParms[i].surfaceFlags; si->contents |= infoParms[i].contents; @@ -177,26 +177,26 @@ static void ParseShaderFile( char *filename ) continue; } // light color - if ( !stricmp( token, "radiocity" ) ) + if ( !stricmp( SC_Token(), "radiocity" ) ) { SC_GetToken( false ); - si->color[0] = atof( token ); + si->color[0] = atof( SC_Token() ); SC_GetToken( false ); - si->color[1] = atof( token ); + si->color[1] = atof( SC_Token() ); SC_GetToken( false ); - si->color[2] = atof( token ); + si->color[2] = atof( SC_Token() ); continue; } // light intensity - if ( !stricmp( token, "intensity" )) + if ( !stricmp( SC_Token(), "intensity" )) { SC_GetToken( false ); - si->intensity = atoi( token ); + si->intensity = atoi( SC_Token() ); continue; } - // ignore all other tokens on the line + // ignore all other SC_Token()s on the line while (SC_TryToken()); } } diff --git a/platform/filesystem.c b/platform/filesystem.c index 1b71348d..6f7d673d 100644 --- a/platform/filesystem.c +++ b/platform/filesystem.c @@ -1506,7 +1506,7 @@ file_t* _FS_Open (const char* filepath, const char* mode, bool quiet, bool nonbl { if (FS_CheckNastyPath(filepath, false)) { - Sys_Error("FS_Open(\"%s\", \"%s\", %s): nasty filename rejected\n", filepath, mode, quiet ? "true" : "false"); + MsgWarn("FS_Open: (\"%s\", \"%s\"): nasty filename rejected\n", filepath, mode ); return NULL; } diff --git a/platform/imglib.c b/platform/imglib.c index c3b6986e..84c1d4d5 100644 --- a/platform/imglib.c +++ b/platform/imglib.c @@ -119,7 +119,7 @@ bool LoadBMP( char *name, char *buffer, int filesize ) *pixbuf++ = 0xff; break; case 16: - shortPixel = * ( unsigned short *)pixbuf; + shortPixel = *(word*)pixbuf; pixbuf += 2; *pixbuf++ = ( shortPixel & ( 31 << 10 ) ) >> 7; *pixbuf++ = ( shortPixel & ( 31 << 5 ) ) >> 2; diff --git a/platform/platform.c b/platform/platform.c index 313f2346..0ecef3c1 100644 --- a/platform/platform.c +++ b/platform/platform.c @@ -7,6 +7,8 @@ #include "baseutils.h" #include "bsplib.h" +bool host_debug = false; + gameinfo_t Plat_GameInfo( void ) { return GI; @@ -14,8 +16,6 @@ gameinfo_t Plat_GameInfo( void ) bool InitPlatform ( int argc, char **argv ) { - char parm[64]; - Msg("------- Loading bin/platform.dll [%g] -------\n", PLATFORM_VERSION ); InitMemory(); @@ -23,12 +23,9 @@ bool InitPlatform ( int argc, char **argv ) ThreadSetDefault(); FS_Init( argc, argv ); - // HACKHACK - bsplib additional cmds - if(FS_GetParmFromCmdLine("-bounce", parm )) - numbounce = atoi(parm); + if(FS_CheckParm("-debug")) + host_debug = true; - if(FS_GetParmFromCmdLine("-ambient", parm )) - ambient = atof(parm) * 128; return true; } diff --git a/platform/platform.h b/platform/platform.h index d9f94d3f..552d73db 100644 --- a/platform/platform.h +++ b/platform/platform.h @@ -61,5 +61,6 @@ bool SC_TryToken ( void ); //safe way void SC_SkipToken( void ); void SC_FreeToken( void ); char *SC_ParseToken(const char **data_p); +char *SC_Token( void ); #endif//BASEPLATFORM_H \ No newline at end of file diff --git a/platform/spritegen.c b/platform/spritegen.c index e86f2141..cac74af0 100644 --- a/platform/spritegen.c +++ b/platform/spritegen.c @@ -116,7 +116,7 @@ void WriteSPRFile (void) { file_t *f; - if(sprite.numframes == 0) Sys_Error ("no frames\n"); + if(sprite.numframes == 0) Sys_Error ("%s have no frames\n", spriteoutname ); if((plump - lumpbuffer) > MAX_BUFFER_SIZE) Sys_Error ("Can't write %s, sprite package too big", spriteoutname ); @@ -189,20 +189,20 @@ syntax "$load fire01.bmp" */ void Cmd_Load (void) { - static byte origpalette[256*3]; - char *name = SC_GetToken ( false ); + static byte origpalette[256*3]; + char *name = SC_GetToken ( false ); dspriteframe_t *pframe; - int x, y, w, h, pix; - byte *screen_p; + int x, y, w, h, pix; + byte *screen_p; FS_DefaultExtension( name, ".bmp" ); byteimage = ReadBMP (name, &lbmpalette, &byteimagewidth, &byteimageheight); if(!byteimage) Sys_Error( "unable to load file \"%s\"\n", name ); - if(sprite.numframes == 0) memcpy( origpalette, lbmpalette, sizeof( origpalette )); + if(sprite.numframes == 0) Mem_Copy( origpalette, lbmpalette, sizeof( origpalette )); else if (memcmp( origpalette, lbmpalette, sizeof( origpalette ))) - Msg("Warning: %s doesn't share a pallette with the previous frame\n", name ); + MsgWarn("Cmd_Load: %s doesn't share a pallette with the previous frame\n", name ); w = byteimagewidth; h = byteimageheight; @@ -280,7 +280,7 @@ void Cmd_Color( void ) g = atoi(SC_GetToken (false)); b = atoi(SC_GetToken (false)); - if (SC_TryToken()) a = atoi(token); + if (SC_TryToken()) a = atoi(SC_Token()); else a = 0xFF;//fullbright //pack into one integer @@ -310,7 +310,7 @@ syntax: "blabla" */ void Cmd_SpriteUnknown( void ) { - MsgDev("Warning: bad command %s\n", token); + MsgWarn("Cmd_SpriteUnknown: bad command %s\n", SC_Token()); while(SC_TryToken()); } diff --git a/platform/studio.c b/platform/studio.c index c1c3bd2e..1c7699b8 100644 --- a/platform/studio.c +++ b/platform/studio.c @@ -15,17 +15,13 @@ char modeloutname[MAX_SYSPATH]; int numrep; int flip_triangles; int dump_hboxes; -int ignore_warnings; int gflags; int cdtextureset; -int maxseqgroupsize; -int split_textures; int clip_texcoords; int numseq; int nummirrored; int numani; -int numseqgroups; int numxnodes; int numrenamedbones; int totalframes = 0; @@ -82,6 +78,7 @@ char mirrored[MAXSTUDIOSRCBONES][64]; s_mesh_t *pmesh; studiohdr_t *phdr; studioseqhdr_t *pseqhdr; +s_sequencegroup_t sequencegroup; s_trianglevert_t (*triangles)[3]; s_model_t *model[MAXSTUDIOMODELS]; s_bbox_t hitbox[MAXSTUDIOSRCBONES]; @@ -94,7 +91,6 @@ s_bonetable_t bonetable[MAXSTUDIOSRCBONES]; s_attachment_t attachment[MAXSTUDIOSRCBONES]; s_renamebone_t renamedbone[MAXSTUDIOSRCBONES]; s_animation_t *panimation[MAXSTUDIOANIMATIONS]; -s_sequencegroup_t sequencegroup[MAXSTUDIOSEQUENCES]; s_bonecontroller_t bonecontroller[MAXSTUDIOSRCBONES]; /* @@ -312,17 +308,14 @@ void WriteSequenceInfo( void ) // save sequence group info pseqgroup = (mstudioseqgroup_t *)pData; - phdr->numseqgroups = numseqgroups; + phdr->numseqgroups = 1; phdr->seqgroupindex = (pData - pStart); - pData += phdr->numseqgroups * sizeof( mstudioseqgroup_t ); + pData += sizeof( mstudioseqgroup_t ); ALIGN( pData ); - for(i = 0; i < numseqgroups; i++) - { - strcpy( pseqgroup[i].label, sequencegroup[i].label ); - strcpy( pseqgroup[i].name, sequencegroup[i].name ); - } + strcpy( pseqgroup->label, sequencegroup.label ); + strcpy( pseqgroup->name, sequencegroup.name ); // save transition graph ptransition = (byte *)pData; @@ -348,9 +341,6 @@ byte *WriteAnimations( byte *pData, byte *pStart, int group ) mstudioanim_t *panim; mstudioanimvalue_t *panimvalue; - // hack for seqgroup 0 - // pseqgroup->data = (pData - pStart); - for (i = 0; i < numseq; i++) { if (sequence[i].seqgroup == group) @@ -383,7 +373,7 @@ byte *WriteAnimations( byte *pData, byte *pStart, int group ) } } } - if (((byte *)panimvalue - (byte *)panim) > 65535) + if (((byte *)panimvalue - (byte *)panim) > 0xffff) Sys_Error("sequence \"%s\" is greater than 64K\n", sequence[i].name ); panim++; } @@ -598,60 +588,11 @@ WriteMDLFile */ void WriteMDLFile (void) { - int i, total = 0; + int total = 0; pStart = Kalloc( FILEBUFFER ); - FS_StripExtension( modeloutname ); - for (i = 1; i < numseqgroups; i++) - { - // write the non-default sequence group data to separate files - char groupname[128], localname[128]; - sprintf( groupname, "%s%02d.mdl", modeloutname, i ); - - Msg("writing %s\n", groupname); - - pseqhdr = (studioseqhdr_t *)pStart; - pseqhdr->id = IDSEQGRPHEADER; - pseqhdr->version = STUDIO_VERSION; - pData = pStart + sizeof( studioseqhdr_t ); - pData = WriteAnimations( pData, pStart, i ); - - FS_FileBase( groupname, localname ); - sprintf( sequencegroup[i].name, "models\\%s.mdl", localname ); - strcpy( pseqhdr->name, sequencegroup[i].name ); - pseqhdr->length = pData - pStart; - - FS_WriteFile( groupname, pStart, pseqhdr->length ); - - Msg("total %6d\n", pseqhdr->length ); - memset( pStart, 0, pseqhdr->length ); - } - - if (split_textures) - { - // write textures out to a separate file - char texname[128]; - - sprintf( texname, "%sT.mdl", modeloutname ); - Msg ("writing %s\n", texname); - - phdr = (studiohdr_t *)pStart; - phdr->id = IDSTUDIOHEADER; - phdr->version = STUDIO_VERSION; - - pData = (byte *)phdr + sizeof( studiohdr_t ); - WriteTextures( ); - phdr->length = pData - pStart; - - FS_WriteFile( texname, pStart, phdr->length ); - - Msg("textures %6d bytes\n", phdr->length ); - memset( pStart, 0, phdr->length ); - pData = pStart; - } - // write the model output file FS_DefaultExtension( modeloutname, ".mdl" ); @@ -685,14 +626,10 @@ void WriteMDLFile (void) Msg("models %6d bytes\n", pData - pStart - total ); total = pData - pStart; - if (!split_textures) - { - WriteTextures(); - Msg("textures %6d bytes\n", pData - pStart - total ); - } + WriteTextures(); + Msg("textures %6d bytes\n", pData - pStart - total ); phdr->length = pData - pStart; - FS_WriteFile( modeloutname, pStart, phdr->length ); Msg("total %6d\n", phdr->length ); } @@ -794,7 +731,7 @@ void SimplifyModel (void) if (n != m) { - Msg("illegal parent bone replacement in model \"%s\"\n\t\"%s\" has \"%s\", previously was \"%s\"\n", model[i]->name, model[i]->node[j].name, (n != -1) ? bonetable[n].name : "ROOT", (m != -1) ? bonetable[m].name : "ROOT" ); + MsgWarn("SimplifyModel: illegal parent bone replacement in model \"%s\"\n\t\"%s\" has \"%s\", previously was \"%s\"\n", model[i]->name, model[i]->node[j].name, (n != -1) ? bonetable[n].name : "ROOT", (m != -1) ? bonetable[m].name : "ROOT" ); iError++; } } @@ -806,7 +743,7 @@ void SimplifyModel (void) } //handle errors - if (iError && !(ignore_warnings)) Sys_Error("unexpected errors, stop compilation\n"); + if (iError && !(host_debug)) Sys_Error("Unexpected errors, stop compilation\nRun with parm \"-debug\" to avoid this"); if (numbones >= MAXSTUDIOBONES) Sys_Error( "Too many bones in model: used %d, max %d\n", numbones, MAXSTUDIOBONES ); // rename sequence bones if needed @@ -845,7 +782,7 @@ void SimplifyModel (void) if (strcmp(szAnim, szNode)) { - Msg("illegal parent bone replacement in sequence \"%s\"\n\t\"%s\" has \"%s\", reference has \"%s\"\n", sequence[i].name, sequence[i].panim[0]->node[j].name, szAnim, szNode ); + MsgWarn("SimplifyModel: illegal parent bone replacement in sequence \"%s\"\n\t\"%s\" has \"%s\", reference has \"%s\"\n", sequence[i].name, sequence[i].panim[0]->node[j].name, szAnim, szNode ); iError++; } sequence[i].panim[0]->bonemap[j] = k; @@ -855,7 +792,7 @@ void SimplifyModel (void) } //handle errors - if (iError && !(ignore_warnings)) Sys_Error("unexpected errors, stop compilation\n"); + if (iError && !(host_debug)) Sys_Error("unexpected errors, stop compilation\nRun with parm \"-debug\" to avoid this"); // link bonecontrollers for (i = 0; i < numbonecontrollers; i++) @@ -867,7 +804,7 @@ void SimplifyModel (void) } if (j >= numbones) { - Msg("Warning: unknown bonecontroller link '%s'\n", bonecontroller[i].name ); + MsgWarn("SimplifyModel: unknown bonecontroller link '%s'\n", bonecontroller[i].name ); j = numbones - 1; } bonecontroller[i].bone = j; @@ -883,7 +820,7 @@ void SimplifyModel (void) } if (j >= numbones) { - Msg("Warning: unknown attachment link '%s'\n", attachment[i].bonename ); + MsgWarn("SimplifyModel: unknown attachment link '%s'\n", attachment[i].bonename ); j = numbones - 1; } attachment[i].bone = j; @@ -908,7 +845,11 @@ void SimplifyModel (void) break; } } - if (k >= numbones) Sys_Error( "cannot find bone %s for hitgroup %d\n", hitgroup[j].name, hitgroup[j].group ); + if (k >= numbones) + { + MsgWarn( "SimplifyModel: cannot find bone %s for hitgroup %d\n", hitgroup[j].name, hitgroup[j].group ); + continue; + } } for (k = 0; k < numbones; k++) @@ -993,7 +934,11 @@ void SimplifyModel (void) break; } } - if (k >= numbones) Sys_Error( "cannot find bone %s for bbox\n", hitbox[j].name ); + if (k >= numbones) + { + MsgWarn("SimplifyModel: cannot find bone %s for bbox\n", hitbox[j].name ); + continue; + } } } @@ -1250,7 +1195,9 @@ void SimplifyModel (void) sequence[i].panim[q]->numanim[j][k] = pvalue - data; if (sequence[i].panim[q]->numanim[j][k] == 2 && value[0] == 0) + { sequence[i].panim[q]->numanim[j][k] = 0; + } else { sequence[i].panim[q]->anim[j][k] = Kalloc( (pvalue - data) * sizeof( mstudioanimvalue_t )); @@ -1261,46 +1208,6 @@ void SimplifyModel (void) } } } - - // auto groups - if (numseqgroups == 1 && maxseqgroupsize < 1024 * 1024) - { - int current = 0; - - numseqgroups = 2; - - for (i = 0; i < numseq; i++) - { - int accum = 0; - - if (sequence[i].activity == 0) - { - for (q = 0; q < sequence[i].numblends; q++) - { - for (j = 0; j < numbones; j++) - { - for (k = 0; k < 6; k++) - { - accum += sequence[i].panim[q]->numanim[j][k] * sizeof( mstudioanimvalue_t ); - } - } - } - accum += sequence[i].numblends * numbones * sizeof( mstudioanim_t ); - - if (current && current + accum > maxseqgroupsize) - { - numseqgroups++; - current = accum; - } - else - { - current += accum; - } - sequence[i].seqgroup = numseqgroups - 1; - } - else sequence[i].seqgroup = 0; - } - } } void Grab_Skin ( s_texture_t *ptexture ) @@ -1445,10 +1352,10 @@ void Grab_Triangles( s_model_t *pmodel ) linecount++; if(SC_MatchToken( "end" )) break;//triangles end - else if(!stricmp( ".bmp", &token[strlen(token)-4])) + else if(!stricmp( ".bmp", &SC_Token()[strlen(SC_Token())-4])) { //probably is texture name - strcpy( texturename, token ); + strcpy( texturename, SC_Token()); // funky texture overrides for (i = 0; i < numrep; i++) @@ -1467,7 +1374,7 @@ void Grab_Triangles( s_model_t *pmodel ) if (strlen(texturename) < 5)//invalid name { // weird model problem, skip them - Msg("Warning: triangle with invalid texname\n"); + MsgWarn("Grab_Triangles: triangle with invalid texname\n"); for(i = 0; i < 3; i++) { if(!SC_GetToken( true )) @@ -1492,7 +1399,7 @@ void Grab_Triangles( s_model_t *pmodel ) else ptriv = lookup_triangle( pmesh, pmesh->numtris ) + j; //grab triangle info - bone = atoi(token); + bone = atoi(SC_Token()); p.org[0] = atof(SC_GetToken( false )); p.org[1] = atof(SC_GetToken( false )); p.org[2] = atof(SC_GetToken( false )); @@ -1501,6 +1408,9 @@ void Grab_Triangles( s_model_t *pmodel ) normal.org[2] = atof(SC_GetToken( false )); ptriv->u = atof(SC_GetToken( false )); ptriv->v = atof(SC_GetToken( false )); + + // skip MilkShape additional info + while(SC_TryToken()); //translate triangles if (bone < 0 || bone >= pmodel->numbones) @@ -1562,13 +1472,13 @@ void Grab_Skeleton( s_node_t *pnodes, s_bone_t *pbones ) { //check time time += atoi(SC_GetToken( false )); - if(time > 0) Msg("Grab_Skeleton: Warning! An animation file is probably used as a reference\n"); + if(time > 0) MsgWarn("Grab_Skeleton: Warning! An animation file is probably used as a reference\n"); continue; } else { //grab skeleton info - index = atoi( token ); + index = atoi( SC_Token()); pbones[index].pos[0] = atof(SC_GetToken( false )); pbones[index].pos[1] = atof(SC_GetToken( false )); pbones[index].pos[2] = atof(SC_GetToken( false )); @@ -1602,7 +1512,7 @@ int Grab_Nodes( s_node_t *pnodes ) //end of nodes description if(SC_MatchToken( "end" )) return numbones + 1; - index = atoi(token); //read bone index (we already have filled token) + index = atoi(SC_Token()); //read bone index (we already have filled token) strcpy( name, SC_GetToken( false )); parent = atoi(SC_GetToken( false )); //read bone parent @@ -1628,7 +1538,7 @@ void Grab_Studio ( s_model_t *pmodel ) FS_DefaultExtension(filename, ".smd" ); load = FS_AddScript( filename, NULL, 0 ); - if(!load)Sys_Error("unable to open %s\n", filename ); + if(!load) Sys_Error("unable to open %s\n", filename ); Msg("grabbing %s\n", filename); linecount = 0; @@ -1641,7 +1551,7 @@ void Grab_Studio ( s_model_t *pmodel ) if (SC_MatchToken( "version" )) { int option = atoi(SC_GetToken( false )); - if (option != 1) Msg("Warning: %s bad version file\n", filename ); + if (option != 1) MsgWarn("Grab_Studio: %s bad version file\n", filename ); } else if (SC_MatchToken( "nodes" )) { @@ -1655,7 +1565,7 @@ void Grab_Studio ( s_model_t *pmodel ) { Grab_Triangles( pmodel ); } - else Msg("unknown studio command %s at line %d\n", token, linecount ); + else MsgWarn("Grab_Studio: unknown studio command %s at line %d\n", SC_Token(), linecount ); } } @@ -1693,7 +1603,7 @@ void Option_Studio( void ) model[nummodels] = Kalloc( sizeof( s_model_t )); bodypart[numbodyparts].pmodel[bodypart[numbodyparts].nummodels] = model[nummodels]; - strncpy( model[nummodels]->name, token, sizeof(model[nummodels]->name)); + strncpy( model[nummodels]->name, SC_Token(), sizeof(model[nummodels]->name)); flip_triangles = 1; scale_up = default_scale; @@ -1750,7 +1660,7 @@ void Cmd_Bodygroup( void ) if (numbodyparts == 0) bodypart[numbodyparts].base = 1; else bodypart[numbodyparts].base = bodypart[numbodyparts-1].base * bodypart[numbodyparts-1].nummodels; - strncpy( bodypart[numbodyparts].name, token, sizeof(bodypart[numbodyparts].name)); + strncpy( bodypart[numbodyparts].name, SC_Token(), sizeof(bodypart[numbodyparts].name)); while( 1 ) { @@ -1781,7 +1691,7 @@ void Cmd_Body( void ) if (numbodyparts == 0) bodypart[numbodyparts].base = 1; else bodypart[numbodyparts].base = bodypart[numbodyparts-1].base * bodypart[numbodyparts-1].nummodels; - strncpy(bodypart[numbodyparts].name, token, sizeof(bodypart[numbodyparts].name)); + strncpy(bodypart[numbodyparts].name, SC_Token(), sizeof(bodypart[numbodyparts].name)); Option_Studio(); numbodyparts++; @@ -1823,7 +1733,7 @@ void Grab_Animation( s_animation_t *panim) } else { - index = atoi(token); + index = atoi(SC_Token()); pos[0] = atof(SC_GetToken( false )); pos[1] = atof(SC_GetToken( false )); pos[2] = atof(SC_GetToken( false )); @@ -1923,7 +1833,7 @@ void Option_Animation ( char *name, s_animation_t *panim ) } else { - Msg("unknown studio command : %s\n", token ); + MsgWarn("Option_Animation: unknown studio command : %s\n", SC_Token() ); while(SC_TryToken());//skip other tokens at line } } @@ -1931,7 +1841,7 @@ void Option_Animation ( char *name, s_animation_t *panim ) int Option_Motion ( s_sequence_t *psequence ) { - while (SC_TryToken()) psequence->motiontype |= lookupControl( token ); + while (SC_TryToken()) psequence->motiontype |= lookupControl( SC_Token()); return 0; } @@ -1939,7 +1849,7 @@ int Option_Event ( s_sequence_t *psequence ) { if (psequence->numevents + 1 >= MAXSTUDIOEVENTS) { - Msg("Warning: MAXSTUDIOEVENTS limit excedeed.\n"); + MsgWarn("Option_Event: MAXSTUDIOEVENTS limit excedeed.\n"); return 0; } @@ -1951,7 +1861,7 @@ int Option_Event ( s_sequence_t *psequence ) if (SC_TryToken()) { if (SC_MatchToken( "}" )) return 1; // opps, hit the end - strcpy( psequence->event[psequence->numevents-1].options, token );// found an option + strcpy( psequence->event[psequence->numevents-1].options, SC_Token());// found an option } return 0; } @@ -1992,7 +1902,7 @@ void Cmd_Origin (void) defaultadjust[1] = atof (SC_GetToken (false)); defaultadjust[2] = atof (SC_GetToken (false)); - if (SC_TryToken()) defaultzrotation = (atof( token ) + 90) * (M_PI / 180.0); + if (SC_TryToken()) defaultzrotation = (atof( SC_Token()) + 90) * (M_PI / 180.0); } @@ -2030,7 +1940,7 @@ syntax: $rotate void Cmd_Rotate(void) { if (!SC_GetToken(false)) return; - zrotation = (atof(token) + 90) * (M_PI / 180.0); + zrotation = (atof(SC_Token()) + 90) * (M_PI / 180.0); } void Option_ScaleUp (void) @@ -2038,35 +1948,6 @@ void Option_ScaleUp (void) scale_up = atof (SC_GetToken (false)); } -/* -============== -Cmd_SequenceGroup - -syntax: $sequencegroup "name" -============== -*/ -int Cmd_SequenceGroup( void ) -{ - strncpy( sequencegroup[numseqgroups].label, SC_GetToken(false), sizeof(sequencegroup[numseqgroups].label)); - numseqgroups++; - - return 0; -} - -/* -============== -Cmd_SequenceGroupSize - -syntax: $sequencegroupsize -============== -*/ -int Cmd_SequenceGroupSize( void ) -{ - //in kilobytes - maxseqgroupsize = 1024 * atoi(SC_GetToken(false)); - return 0; -} - /* ============== Cmd_Sequence @@ -2101,7 +1982,7 @@ int Cmd_Sequence( void ) if(!SC_GetToken(false)) return 0; - strncpy( sequence[numseq].name, token, sizeof(sequence[numseq].name)); + strncpy( sequence[numseq].name, SC_Token(), sizeof(sequence[numseq].name)); VectorCopy( defaultadjust, adjust ); scale_up = default_scale; @@ -2109,7 +1990,7 @@ int Cmd_Sequence( void ) //set default values zrotation = defaultzrotation; sequence[numseq].fps = 30.0; - sequence[numseq].seqgroup = numseqgroups - 1; + sequence[numseq].seqgroup = 0; sequence[numseq].blendstart[0] = 0.0; sequence[numseq].blendend[0] = 1.0; @@ -2156,37 +2037,37 @@ int Cmd_Sequence( void ) sequence[numseq].exitnode = atoi(SC_GetToken( false )); sequence[numseq].nodeflags |= 1; } - else if (lookupControl( token ) != -1) + else if (lookupControl( SC_Token()) != -1) { - sequence[numseq].motiontype |= lookupControl( token ); + sequence[numseq].motiontype |= lookupControl( SC_Token()); } else if (SC_MatchToken( "animation" )) { strncpy( smdfilename[numblends], SC_GetToken( false ), sizeof(smdfilename[numblends])); numblends++; } - else if (i = lookupActivity( token )) + else if (i = lookupActivity( SC_Token())) { sequence[numseq].activity = i; sequence[numseq].actweight = 1;//default weight if(SC_TryToken()) { //make sure what is really actweight - if(!SC_MatchToken("{") && !SC_MatchToken("}") && strlen(token) < 3 && atoi(token) <= 100) - sequence[numseq].actweight = atoi(token); + if(!SC_MatchToken("{") && !SC_MatchToken("}") && strlen(SC_Token()) < 3 && atoi(SC_Token()) <= 100) + sequence[numseq].actweight = atoi(SC_Token()); else SC_FreeToken();//release token } } else { - strncpy( smdfilename[numblends], token, sizeof(smdfilename[numblends])); + strncpy( smdfilename[numblends], SC_Token(), sizeof(smdfilename[numblends])); numblends++; } - if (depth < 0) Sys_Error("missing {\n"); } + if (numblends == 0) { - Msg("Warning: sequence \"%s\" has no animations. skipped...\n", sequence[numseq].name); + MsgWarn("Cmd_Sequence: \"%s\" has no animations. skipped...\n", sequence[numseq].name); return 0; } for (i = 0; i < numblends; i++) @@ -2216,7 +2097,7 @@ int Cmd_Root (void) { if (SC_GetToken(false)) { - strncpy( pivotname[0], token, sizeof(pivotname)); + strncpy( pivotname[0], SC_Token(), sizeof(pivotname)); return 0; } return 1; @@ -2233,10 +2114,10 @@ int Cmd_Pivot (void) { if (SC_GetToken (false)) { - int index = atoi(token); + int index = atoi(SC_Token()); if (SC_GetToken(false)) { - strncpy( pivotname[index], token, sizeof(pivotname[index])); + strncpy( pivotname[index], SC_Token(), sizeof(pivotname[index])); return 0; } } @@ -2256,16 +2137,16 @@ int Cmd_Controller (void) { //mouth is hardcoded at four controller if (SC_MatchToken( "mouth" )) bonecontroller[numbonecontrollers].index = 4; - else bonecontroller[numbonecontrollers].index = atoi(token); + else bonecontroller[numbonecontrollers].index = atoi(SC_Token()); if (SC_GetToken(false)) { - strncpy( bonecontroller[numbonecontrollers].name, token, sizeof(bonecontroller[numbonecontrollers].name)); + strncpy( bonecontroller[numbonecontrollers].name, SC_Token(), sizeof(bonecontroller[numbonecontrollers].name)); SC_GetToken(false); - if ((bonecontroller[numbonecontrollers].type = lookupControl(token)) == -1) + if ((bonecontroller[numbonecontrollers].type = lookupControl(SC_Token())) == -1) { - Msg("Cmd_Controller: unknown bonecontroller type '%s'\n", token ); + MsgWarn("Cmd_Controller: unknown bonecontroller type '%s'\n", SC_Token() ); return 0; } @@ -2361,8 +2242,12 @@ int Cmd_TextureGroup( void ) int index = 0; int group = 0; - if (numtextures == 0) Sys_Error( "texturegroups must follow model loading\n"); - + if (numtextures == 0) + { + MsgWarn("Cmd_TextureGroup: texturegroups must follow model loading\n"); + return 0; + } + if (!SC_GetToken(false)) return 0; if (numskinref == 0) numskinref = numtextures; @@ -2370,7 +2255,7 @@ int Cmd_TextureGroup( void ) { if(!SC_GetToken(true)) { - if (depth) Sys_Error("missing }\n" ); + if (depth)MsgWarn("missing }\n"); break; } @@ -2384,7 +2269,7 @@ int Cmd_TextureGroup( void ) } else if (depth == 2) { - i = lookup_texture( token ); + i = lookup_texture( SC_Token()); texturegroup[numtexturegroups][group][index] = i; if (group != 0) texture[i].parent = texturegroup[numtexturegroups][0][index]; index++; @@ -2501,7 +2386,7 @@ void Cmd_TexRenderMode( void ) { texture[lookup_texture(tex_name)].flags |= STUDIO_NF_BLENDED; } - else Msg("Texture '%s' has unknown render mode '%s'!\n", tex_name, token); + else MsgWarn("Cmd_TexRenderMode: texture '%s' have unknown render mode '%s'!\n", tex_name, SC_Token()); } @@ -2561,16 +2446,12 @@ void ResetModelInfo( void ) numrep = 0; gamma = 1.8; flip_triangles = 1; - maxseqgroupsize = 1024 * 1024; normal_blend = cos( 2.0 * (M_PI / 180.0)); //make an option dump_hboxes = 0; - ignore_warnings = 0; - - strcpy( sequencegroup[numseqgroups].label, "default" ); - numseqgroups = 1; + strcpy( sequencegroup.label, "default" ); FS_ClearSearchPath();//clear all $cd and $cdtexture //set default model parms @@ -2587,7 +2468,7 @@ syntax: "blabla" */ void Cmd_StudioUnknown( void ) { - MsgWarn("Cmd_StudioUnknown: skip command \"%s\"\n", token); + MsgWarn("Cmd_StudioUnknown: skip command \"%s\"\n", SC_Token()); while(SC_TryToken()); } @@ -2601,7 +2482,7 @@ bool ParseModelScript (void) if (SC_MatchToken("$modelname")) Cmd_Modelname (); else if (SC_MatchToken("$cd")) Cmd_CdSet(); - else if (!strcmp (token, "$cdtexture")) Cmd_CdTextureSet(); + else if (SC_MatchToken("$cdtexture")) Cmd_CdTextureSet(); else if (SC_MatchToken("$scale")) Cmd_ScaleUp (); else if (SC_MatchToken("$rotate")) Cmd_Rotate(); else if (SC_MatchToken("$root")) Cmd_Root (); @@ -2610,8 +2491,6 @@ bool ParseModelScript (void) else if (SC_MatchToken("$body")) Cmd_Body(); else if (SC_MatchToken("$bodygroup")) Cmd_Bodygroup(); else if (SC_MatchToken("$sequence")) Cmd_Sequence (); - else if (SC_MatchToken("$sequencegroup")) Cmd_SequenceGroup (); - else if (SC_MatchToken("$sequencegroupsize")) Cmd_SequenceGroupSize (); else if (SC_MatchToken("$eyeposition")) Cmd_Eyeposition (); else if (SC_MatchToken("$origin")) Cmd_Origin (); else if (SC_MatchToken("$bbox")) Cmd_BBox (); @@ -2622,9 +2501,7 @@ bool ParseModelScript (void) else if (SC_MatchToken("$hgroup")) Cmd_Hitgroup (); else if (SC_MatchToken("$hbox")) Cmd_Hitbox (); else if (SC_MatchToken("$attachment")) Cmd_Attachment (); - else if (SC_MatchToken("$externaltextures")) split_textures = 1; else if (SC_MatchToken("$cliptotextures")) clip_texcoords = 1; - else if (SC_MatchToken("$debug")) ignore_warnings = 1; else if (SC_MatchToken("$renamebone")) Cmd_Renamebone (); else if (SC_MatchToken("$texrendermode")) Cmd_TexRenderMode(); else if (SC_MatchToken("$replacetexture")) Cmd_Replace(); @@ -2653,7 +2530,7 @@ void ClearModel( void ) cdset = false; cdtextureset = 0; - numrep = gflags = maxseqgroupsize = numseq = nummirrored = numseqgroups = 0; + numrep = gflags = numseq = nummirrored = 0; numxnodes = numrenamedbones = totalframes = numbones = numhitboxes = 0; numhitgroups = numattachments = numtextures = numskinref = numskinfamilies = 0; numbonecontrollers = numtexturegroups = numcommandnodes = numbodyparts = 0; diff --git a/platform/studio_utils.c b/platform/studio_utils.c index 2fbe09b0..361b13aa 100644 --- a/platform/studio_utils.c +++ b/platform/studio_utils.c @@ -717,7 +717,7 @@ s_mesh_t *lookup_mesh( s_model_t *pmodel, char *texturename ) return pmodel->pmesh[i]; } - if (i >= MAXSTUDIOMESHES) Sys_Error( "too many textures in model: \"%s\"\n", pmodel->name ); + if (i >= MAXSTUDIOMESHES) Sys_Error( "too many meshes in model: \"%s\"\n", pmodel->name ); pmodel->nummesh = i + 1; pmodel->pmesh[i] = Kalloc( sizeof( s_mesh_t ) ); diff --git a/public/const.h b/public/const.h index 06ad3468..69bcffb2 100644 --- a/public/const.h +++ b/public/const.h @@ -1004,17 +1004,6 @@ typedef struct short stats[MAX_STATS]; // fast status bar updates } player_state_t; - -// ================== -// PGM -#define VIDREF_GL 1 -#define VIDREF_SOFT 2 -#define VIDREF_OTHER 3 - -extern int vidref_val; -// PGM -// ================== - typedef enum { FOOTSTEP_METAL1, diff --git a/public/studio.h b/public/studio.h index aa77bf42..49784128 100644 --- a/public/studio.h +++ b/public/studio.h @@ -20,20 +20,20 @@ Studio models are position independent, so the cache manager can move them. #define IDSEQGRPHEADER (('Q'<<24)+('S'<<16)+('D'<<8)+'I') // little-endian "IDSQ" // studio limits -#define MAXSTUDIOTRIANGLES 20000 // TODO: tune this +#define MAXSTUDIOTRIANGLES 32768 // max triangles per model #define MAXSTUDIOVERTS 4096 // max vertices per submodel #define MAXSTUDIOSEQUENCES 256 // total animation sequences #define MAXSTUDIOSKINS 128 // total textures #define MAXSTUDIOSRCBONES 512 // bones allowed at source movement #define MAXSTUDIOBONES 128 // total bones actually used #define MAXSTUDIOMODELS 32 // sub-models per model -#define MAXSTUDIOBODYPARTS 32 +#define MAXSTUDIOBODYPARTS 32 // body parts per submodel #define MAXSTUDIOGROUPS 16 // sequence groups (e.g. barney01.mdl, barney02.mdl, e.t.c) #define MAXSTUDIOANIMATIONS 512 // max frames per sequence #define MAXSTUDIOMESHES 256 // max textures per model -#define MAXSTUDIOEVENTS 1024 -#define MAXSTUDIOPIVOTS 256 -#define MAXSTUDIOBLENDS 2 // TODO: tune this +#define MAXSTUDIOEVENTS 1024 // events per model +#define MAXSTUDIOPIVOTS 256 // pivot points +#define MAXSTUDIOBLENDS 8 // max anim blends #define MAXSTUDIOCONTROLLERS 32 // max controllers per model #define MAXSTUDIOATTACHMENTS 32 // max attachments per model diff --git a/release.bat b/release.bat index 33024c26..310e3fcb 100644 --- a/release.bat +++ b/release.bat @@ -21,7 +21,7 @@ if errorlevel 1 set BUILD_ERROR=1 %MSDEV% platform/platform.dsp %CONFIG%"platform - Win32 Release" %build_target% if errorlevel 1 set BUILD_ERROR=1 -%MSDEV% render/render.dsp %CONFIG%"render - Win32 Release" %build_target% +%MSDEV% renderer/renderer.dsp %CONFIG%"renderer - Win32 Release" %build_target% if errorlevel 1 set BUILD_ERROR=1 %MSDEV% server/server.dsp %CONFIG%"server - Win32 Release" %build_target% @@ -49,7 +49,7 @@ rem //delete log files if exist engine\engine.plg del /f /q engine\engine.plg if exist launcher\launcher.plg del /f /q launcher\launcher.plg if exist platform\platform.plg del /f /q platform\platform.plg -if exist render\render.plg del /f /q render\render.plg +if exist renderer\renderer.plg del /f /q renderer\renderer.plg if exist server\server.plg del /f /q server\server.plg echo Build succeeded! diff --git a/render/anormtab.h b/renderer/anormtab.h similarity index 100% rename from render/anormtab.h rename to renderer/anormtab.h diff --git a/render/gl_draw.c b/renderer/gl_draw.c similarity index 100% rename from render/gl_draw.c rename to renderer/gl_draw.c diff --git a/render/gl_light.c b/renderer/gl_light.c similarity index 100% rename from render/gl_light.c rename to renderer/gl_light.c diff --git a/render/gl_local.h b/renderer/gl_local.h similarity index 96% rename from render/gl_local.h rename to renderer/gl_local.h index ff7cefdb..cee18aa8 100644 --- a/render/gl_local.h +++ b/renderer/gl_local.h @@ -321,7 +321,6 @@ extern cvar_t *gl_modulate; extern cvar_t *gl_playermip; extern cvar_t *gl_drawbuffer; extern cvar_t *gl_3dlabs_broken; -extern cvar_t *gl_driver; extern cvar_t *gl_swapinterval; extern cvar_t *gl_texturemode; extern cvar_t *gl_texturealphamode; diff --git a/render/gl_mesh.c b/renderer/gl_mesh.c similarity index 100% rename from render/gl_mesh.c rename to renderer/gl_mesh.c diff --git a/render/gl_model.c b/renderer/gl_model.c similarity index 100% rename from render/gl_model.c rename to renderer/gl_model.c diff --git a/render/gl_model.h b/renderer/gl_model.h similarity index 100% rename from render/gl_model.h rename to renderer/gl_model.h diff --git a/render/gl_rmain.c b/renderer/gl_rmain.c similarity index 94% rename from render/gl_rmain.c rename to renderer/gl_rmain.c index 5c09c4f0..82926ed1 100644 --- a/render/gl_rmain.c +++ b/renderer/gl_rmain.c @@ -112,7 +112,6 @@ cvar_t *r_motionblur; cvar_t *gl_log; cvar_t *gl_bitdepth; cvar_t *gl_drawbuffer; -cvar_t *gl_driver; cvar_t *gl_lightmap; cvar_t *gl_shadows; cvar_t *gl_mode; @@ -148,7 +147,6 @@ cvar_t *gl_3dlabs_broken; cvar_t *vid_fullscreen; cvar_t *vid_gamma; -cvar_t *vid_ref; /* ================= @@ -961,7 +959,6 @@ void R_Register( void ) gl_polyblend = ri.Cvar_Get ("gl_polyblend", "1", 0); gl_flashblend = ri.Cvar_Get ("gl_flashblend", "0", 0); gl_playermip = ri.Cvar_Get ("gl_playermip", "0", 0); - gl_driver = ri.Cvar_Get( "gl_driver", "opengl32", CVAR_ARCHIVE ); gl_texturemode = ri.Cvar_Get( "gl_texturemode", "GL_LINEAR_MIPMAP_NEAREST", CVAR_ARCHIVE ); gl_texturealphamode = ri.Cvar_Get( "gl_texturealphamode", "default", CVAR_ARCHIVE ); gl_texturesolidmode = ri.Cvar_Get( "gl_texturesolidmode", "default", CVAR_ARCHIVE ); @@ -984,7 +981,6 @@ void R_Register( void ) vid_fullscreen = ri.Cvar_Get( "vid_fullscreen", "0", CVAR_ARCHIVE ); vid_gamma = ri.Cvar_Get( "vid_gamma", "1.0", CVAR_ARCHIVE ); - vid_ref = ri.Cvar_Get( "vid_ref", "soft", CVAR_ARCHIVE ); ri.Cmd_AddCommand( "imagelist", R_ImageList_f ); ri.Cmd_AddCommand( "screenshot", GL_ScreenShot_f ); @@ -1072,18 +1068,17 @@ int R_Init( void *hinstance, void *hWnd ) R_Register(); // initialize our QGL dynamic bindings - if ( !QGL_Init( gl_driver->string ) ) + if ( !QGL_Init( "opengl32" ) ) { QGL_Shutdown(); - Msg("R_Init() - could not load \"%s\"\n", gl_driver->string ); - return -1; + return false; } // initialize OS-specific parts of OpenGL if ( !GLimp_Init( hinstance, hWnd ) ) { QGL_Shutdown(); - return -1; + return false; } // set our "safe" modes @@ -1094,9 +1089,10 @@ int R_Init( void *hinstance, void *hWnd ) { QGL_Shutdown(); Msg( "R_Init() - could not R_SetMode()\n" ); - return -1; + return false; } + Msg("------- Loading bin/renderer.dll [%g] -------\n", RENDERER_VERSION ); ri.Vid_MenuInit(); //get our various GL strings @@ -1303,17 +1299,6 @@ void R_BeginFrame( float camera_separation ) gl_state.camera_separation = camera_separation; - /* - ** change modes if necessary - */ - if ( gl_mode->modified || vid_fullscreen->modified ) - { // FIXME: only restart if CDS is required - cvar_t *ref; - - ref = ri.Cvar_Get ("vid_ref", "gl", 0); - ref->modified = true; - } - if ( gl_log->modified ) { GLimp_EnableLogging( gl_log->value ); diff --git a/render/gl_rmisc.c b/renderer/gl_rmisc.c similarity index 100% rename from render/gl_rmisc.c rename to renderer/gl_rmisc.c diff --git a/render/gl_rsurf.c b/renderer/gl_rsurf.c similarity index 100% rename from render/gl_rsurf.c rename to renderer/gl_rsurf.c diff --git a/render/gl_warp.c b/renderer/gl_warp.c similarity index 100% rename from render/gl_warp.c rename to renderer/gl_warp.c diff --git a/render/gl_widnt.c b/renderer/gl_widnt.c similarity index 97% rename from render/gl_widnt.c rename to renderer/gl_widnt.c index 09bb4304..b57f5314 100644 --- a/render/gl_widnt.c +++ b/renderer/gl_widnt.c @@ -3044,7 +3044,7 @@ bool QGL_Init( const char *dllname ) putenv( envbuffer ); } - if ( ( glw_state.hinstOpenGL = LoadLibrary( dllname ) ) == 0 ) + if (( glw_state.hinstOpenGL = LoadLibrary( dllname ) ) == 0 ) { char *buf = NULL; diff --git a/render/glw_imp.c b/renderer/glw_imp.c similarity index 94% rename from render/glw_imp.c rename to renderer/glw_imp.c index 8cea1d98..82c030be 100644 --- a/render/glw_imp.c +++ b/renderer/glw_imp.c @@ -41,7 +41,6 @@ glwstate_t glw_state; static char wndname[128]; extern cvar_t *vid_fullscreen; -extern cvar_t *vid_ref; static bool VerifyDriver( void ) { @@ -427,14 +426,7 @@ bool GLimp_InitGL (void) gl_state.stereo_enabled = false; } - /* - ** figure out if we're running on a minidriver or not - */ - if ( strstr( gl_driver->string, "opengl32" ) != 0 ) - glw_state.minidriver = false; - else - glw_state.minidriver = true; - + glw_state.minidriver = false; /* ** Get a DC for the specified window */ diff --git a/render/lhfont.h b/renderer/lhfont.h similarity index 100% rename from render/lhfont.h rename to renderer/lhfont.h diff --git a/render/palette.h b/renderer/palette.h similarity index 100% rename from render/palette.h rename to renderer/palette.h diff --git a/render/r_backend.c b/renderer/r_backend.c similarity index 100% rename from render/r_backend.c rename to renderer/r_backend.c diff --git a/render/r_bloom.c b/renderer/r_bloom.c similarity index 100% rename from render/r_bloom.c rename to renderer/r_bloom.c diff --git a/render/r_bspmod.c b/renderer/r_bspmod.c similarity index 100% rename from render/r_bspmod.c rename to renderer/r_bspmod.c diff --git a/render/r_opengl.h b/renderer/r_opengl.h similarity index 100% rename from render/r_opengl.h rename to renderer/r_opengl.h diff --git a/render/r_sprite.c b/renderer/r_sprite.c similarity index 100% rename from render/r_sprite.c rename to renderer/r_sprite.c diff --git a/render/r_studio.c b/renderer/r_studio.c similarity index 100% rename from render/r_studio.c rename to renderer/r_studio.c diff --git a/render/r_texture.c b/renderer/r_texture.c similarity index 100% rename from render/r_texture.c rename to renderer/r_texture.c diff --git a/render/r_utils.c b/renderer/r_utils.c similarity index 100% rename from render/r_utils.c rename to renderer/r_utils.c diff --git a/render/render.dsp b/renderer/renderer.dsp similarity index 74% rename from render/render.dsp rename to renderer/renderer.dsp index a7621174..184f84ed 100644 --- a/render/render.dsp +++ b/renderer/renderer.dsp @@ -1,24 +1,24 @@ -# Microsoft Developer Studio Project File - Name="render" - Package Owner=<4> +# Microsoft Developer Studio Project File - Name="renderer" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 -CFG=render - Win32 Release +CFG=renderer - Win32 Release !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE -!MESSAGE NMAKE /f "render.mak". +!MESSAGE NMAKE /f "renderer.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE -!MESSAGE NMAKE /f "render.mak" CFG="render - Win32 Release" +!MESSAGE NMAKE /f "renderer.mak" CFG="renderer - Win32 Release" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE -!MESSAGE "render - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "render - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "renderer - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "renderer - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project @@ -29,17 +29,17 @@ CPP=cl.exe MTL=midl.exe RSC=rc.exe -!IF "$(CFG)" == "render - Win32 Release" +!IF "$(CFG)" == "renderer - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir ".\render__" -# PROP BASE Intermediate_Dir ".\render__" +# PROP BASE Output_Dir ".\renderer__" +# PROP BASE Intermediate_Dir ".\renderer__" # PROP BASE Target_Dir "." # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 -# PROP Output_Dir "..\temp\render\!release" -# PROP Intermediate_Dir "..\temp\render\!release" +# PROP Output_Dir "..\temp\renderer\!release" +# PROP Intermediate_Dir "..\temp\renderer\!release" # PROP Ignore_Export_Lib 1 # PROP Target_Dir "." # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c @@ -57,26 +57,26 @@ LINK32=link.exe # ADD LINK32 kernel32.lib user32.lib gdi32.lib /nologo /subsystem:windows /dll /pdb:none /machine:I386 /libpath:"../public/libs/" # SUBTRACT LINK32 /debug # Begin Custom Build -TargetDir=\Xash3D\src_main\!source\temp\render\!release -InputPath=\Xash3D\src_main\!source\temp\render\!release\render.dll +TargetDir=\XASH3D\src_main\!source\temp\renderer\!release +InputPath=\XASH3D\src_main\!source\temp\renderer\!release\renderer.dll SOURCE="$(InputPath)" -"D:\Xash3D\bin\render.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - copy $(TargetDir)\render.dll "D:\Xash3D\bin\render.dll" +"D:\Xash3D\bin\renderer.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + copy $(TargetDir)\renderer.dll "D:\Xash3D\bin\renderer.dll" # End Custom Build -!ELSEIF "$(CFG)" == "render - Win32 Debug" +!ELSEIF "$(CFG)" == "renderer - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir ".\render__" -# PROP BASE Intermediate_Dir ".\render__" +# PROP BASE Output_Dir ".\renderer__" +# PROP BASE Intermediate_Dir ".\renderer__" # PROP BASE Target_Dir "." # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 -# PROP Output_Dir "..\temp\render\!debug" -# PROP Intermediate_Dir "..\temp\render\!debug" +# PROP Output_Dir "..\temp\renderer\!debug" +# PROP Intermediate_Dir "..\temp\renderer\!debug" # PROP Ignore_Export_Lib 1 # PROP Target_Dir "." # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c @@ -94,12 +94,12 @@ LINK32=link.exe # ADD LINK32 kernel32.lib user32.lib gdi32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libc.lib" /pdbtype:sept /libpath:"../public/libs/" # SUBTRACT LINK32 /profile /incremental:no /map # Begin Custom Build -TargetDir=\Xash3D\src_main\!source\temp\render\!debug -InputPath=\Xash3D\src_main\!source\temp\render\!debug\render.dll +TargetDir=\XASH3D\src_main\!source\temp\renderer\!debug +InputPath=\XASH3D\src_main\!source\temp\renderer\!debug\renderer.dll SOURCE="$(InputPath)" -"D:\Xash3D\bin\render.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - copy $(TargetDir)\render.dll "D:\Xash3D\bin\render.dll" +"D:\Xash3D\bin\renderer.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + copy $(TargetDir)\renderer.dll "D:\Xash3D\bin\renderer.dll" # End Custom Build @@ -107,8 +107,8 @@ SOURCE="$(InputPath)" # Begin Target -# Name "render - Win32 Release" -# Name "render - Win32 Debug" +# Name "renderer - Win32 Release" +# Name "renderer - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90" @@ -226,7 +226,7 @@ SOURCE=..\client\ref.h # End Source File # Begin Source File -SOURCE=.\render.h +SOURCE=.\renderer.h # End Source File # Begin Source File diff --git a/render/warpsin.h b/renderer/warpsin.h similarity index 100% rename from render/warpsin.h rename to renderer/warpsin.h diff --git a/server/ents/g_fog.c b/server/ents/g_fog.c index 00fbfa55..f76aca0b 100644 --- a/server/ents/g_fog.c +++ b/server/ents/g_fog.c @@ -1,30 +1,4 @@ #include "g_local.h" - -//#define DISABLE_FOG - -#ifdef DISABLE_FOG -void Fog_Init() -{ -} -void Fog(vec3_t viewpoint) -{ -} -void Fog_Off() -{ -} -void SP_trigger_fog(edict_t *self) -{ - G_FreeEdict(self); -} -void SP_target_fog(edict_t *self) -{ - G_FreeEdict(self); -} -void Cmd_Fog_f(edict_t *ent) -{ -} -#else - #include #define __MSC__ #include @@ -354,7 +328,6 @@ void GlideFogTable() float w, dw4; if(!hGlide) return; - if(strcmp(gl_driver->string,"3dfxgl") || strcmp(vid_ref->string,"gl") ) return; if(last_software_frame + 10 > level.framenum) return; if(last_opengl_frame + 10 > level.framenum) return; @@ -517,19 +490,9 @@ void Fog(vec3_t viewpoint) edict_t *triggerfog; edict_t *player = &g_edicts[1]; - if(!gl_driver || !vid_ref) - return; - if(deathmatch->value || coop->value) return; - if(stricmp(vid_ref->string,"gl")) - { - last_software_frame = level.framenum; - level.active_fog = 0; - return; - } - InTriggerFog = false; if(level.trigger_fogs) { @@ -942,25 +905,4 @@ void SP_trigger_fog (edict_t *self) self->solid = SOLID_NOT; gi.setmodel (self, self->model); gi.linkentity(self); -} -#endif - -/* -void SetChromakey() -{ - if(!gl_driver || !vid_ref) - return; - - if(stricmp(vid_ref->string,"gl")) - return; - - if(!strcmp(gl_driver->string,"3dfxgl")) - { - Glide_grChromakeyMode(GR_CHROMAKEY_ENABLE); - Glide_grChromakeyValue(0xFF); - } - else - { - } -} -*/ \ No newline at end of file +} \ No newline at end of file diff --git a/server/ents/g_target.c b/server/ents/g_target.c index a9b9e5f2..8a7177bd 100644 --- a/server/ents/g_target.c +++ b/server/ents/g_target.c @@ -3550,25 +3550,16 @@ void use_target_failure (edict_t *self, edict_t *other, edict_t *activator) gi.sound (activator, CHAN_VOICE|CHAN_RELIABLE, self->noise_index, 1, ATTN_NORM, 0); self->target_ent = activator; - if(stricmp(vid_ref->string,"gl")) - { - self->flags = 12; - self->think = target_failure_fade_lights; - self->nextthink = level.time + FRAMETIME; - } - else - { - activator->client->fadestart= level.framenum; - activator->client->fadein = level.framenum + 40; - activator->client->fadehold = activator->client->fadein + 100000; - activator->client->fadeout = 0; - activator->client->fadecolor[0] = 0; - activator->client->fadecolor[1] = 0; - activator->client->fadecolor[2] = 0; - activator->client->fadealpha = 1.0; - self->think = target_failure_think; - self->nextthink = level.time + 4; - } + activator->client->fadestart= level.framenum; + activator->client->fadein = level.framenum + 40; + activator->client->fadehold = activator->client->fadein + 100000; + activator->client->fadeout = 0; + activator->client->fadecolor[0] = 0; + activator->client->fadecolor[1] = 0; + activator->client->fadecolor[2] = 0; + activator->client->fadealpha = 1.0; + self->think = target_failure_think; + self->nextthink = level.time + 4; activator->deadflag = DEAD_FROZEN; gi.linkentity(activator); } diff --git a/server/g_local.h b/server/g_local.h index 42625a90..7268d0e4 100644 --- a/server/g_local.h +++ b/server/g_local.h @@ -758,10 +758,9 @@ extern cvar_t *rotate_distance; extern cvar_t *s_primary; extern cvar_t *shift_distance; extern cvar_t *sv_maxgibs; -extern cvar_t *tpp; // third person perspective +extern cvar_t *tpp; // third person perspective extern cvar_t *tpp_auto; extern cvar_t *turn_rider; -extern cvar_t *vid_ref; extern cvar_t *zoomrate; extern cvar_t *zoomsnap; diff --git a/server/global/g_main.c b/server/global/g_main.c index 463b01a2..81a65557 100644 --- a/server/global/g_main.c +++ b/server/global/g_main.c @@ -104,7 +104,6 @@ cvar_t *s_primary; cvar_t *shift_distance; cvar_t *sv_maxgibs; cvar_t *turn_rider; -cvar_t *vid_ref; cvar_t *zoomrate; cvar_t *zoomsnap; @@ -206,7 +205,6 @@ game_export_t DLLEXPORT *ServerAPI (game_import_t *import) globals.edict_size = sizeof(edict_t); gl_driver = gi.cvar ("gl_driver", "", 0); - vid_ref = gi.cvar ("vid_ref", "", 0); gl_driver_fog = gi.cvar ("gl_driver_fog", "opengl32", CVAR_NOSET | CVAR_ARCHIVE); Fog_Init(); diff --git a/server/p_view.c b/server/p_view.c index b7f470e1..6f2b870f 100644 --- a/server/p_view.c +++ b/server/p_view.c @@ -554,8 +554,7 @@ void SV_CalcBlend (edict_t *ent) float alpha; // Turn off fade for dead software players or they won't see menu - if((ent->health <= 0) && (stricmp(vid_ref->string,"gl"))) - ent->client->fadein = 0; + if(ent->health <= 0) ent->client->fadein = 0; if(ent->client->fadein > level.framenum) { @@ -580,8 +579,7 @@ void SV_CalcBlend (edict_t *ent) ent->client->fadecolor[2], alpha, ent->client->ps.blend); } - else - ent->client->fadein = 0; + else ent->client->fadein = 0; } } diff --git a/server/server.dsp b/server/server.dsp index 9f49fa6b..171b1fc4 100644 --- a/server/server.dsp +++ b/server/server.dsp @@ -54,11 +54,11 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 -# ADD LINK32 kernel32.lib user32.lib winmm.lib /nologo /subsystem:windows /dll /pdb:none /machine:I386 /out:"..\temp\render\!release/server.dll" +# ADD LINK32 kernel32.lib user32.lib winmm.lib /nologo /subsystem:windows /dll /pdb:none /machine:I386 # SUBTRACT LINK32 /debug # Begin Custom Build -TargetDir=\XASH3D\src_main\!source\temp\render\!release -InputPath=\XASH3D\src_main\!source\temp\render\!release\server.dll +TargetDir=\XASH3D\src_main\!source\temp\server\!release +InputPath=\XASH3D\src_main\!source\temp\server\!release\server.dll SOURCE="$(InputPath)" "D:\Xash3D\xash\bin\server.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" @@ -91,11 +91,11 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 -# ADD LINK32 kernel32.lib user32.lib winmm.lib /nologo /subsystem:windows /dll /debug /machine:I386 /out:"..\temp\render\!debug/server.dll" +# ADD LINK32 kernel32.lib user32.lib winmm.lib /nologo /subsystem:windows /dll /debug /machine:I386 # SUBTRACT LINK32 /incremental:no /map # Begin Custom Build -TargetDir=\XASH3D\src_main\!source\temp\render\!debug -InputPath=\XASH3D\src_main\!source\temp\render\!debug\server.dll +TargetDir=\XASH3D\src_main\!source\temp\server\!debug +InputPath=\XASH3D\src_main\!source\temp\server\!debug\server.dll SOURCE="$(InputPath)" "D:\Xash3D\xash\bin\server.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" diff --git a/xash.dsw b/xash.dsw index 8fb9c6d8..e223c96d 100644 --- a/xash.dsw +++ b/xash.dsw @@ -51,7 +51,7 @@ Package=<4> ############################################################################### -Project: "render"=".\render\render.dsp" - Package Owner=<4> +Project: "renderer"=".\renderer\renderer.dsp" - Package Owner=<4> Package=<5> {{{