Skip to content

Commit

Permalink
sane defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
d3nd3 committed Jul 16, 2024
1 parent fb5de69 commit d333b6d
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 9 deletions.
18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,27 @@
* **Lighting blend mode adjustment** (if compile with #define FEATURE_ALT_LIGHTING in hdr/features.h)
* **Font Scaling**
* **Console Size Adjustment**
* **Sane first time settings for SoF init if del config.cfg eg.**

## Usage
### Wine/Proton
If you are on linux, I highly recommend using wine instead of proton. There is less screen tearing, when using true fullscreen (drm.modeset), only noticeable in slight moments.
`wine SoF.exe +set console 1 +set cddir CDDIR +set wine %command%`
If you are on linux, I highly recommend using wine instead of proton. There is less screen tearing, when using true fullscreen (drm.modeset), only noticeable in slight moments. (Because wine has less tearing and less glitchy gun effects/visuals.)

`wine SoF.exe +set console 1 +set cddir CDDIR #%command%`
However, if you do decide to use Proton, I recommend <= 4.11-13 , else you have to adjust sound frequency each startup. (It sticks to 11, but 22 is better).

Because wine has less tearing and less glitchy gun effects/visuals.
Optimal FPS, especially if using wine:
base/autoexec.cfg:
```
cl_quads 0
ghl_light_method 0
ghl_shadows 0
```


### Installation + Setup
It is recommended to delete your User/config.cfg file before install so that you get optimal defaults.

Either compile the project using `make` or grab the pre-compiled from release section.
Ensure/place the `sof_buddy.dll` file is in your root SoF folder, along with the other 4 scripts.
(dump everything into the root SoF folder)
Expand Down
13 changes: 13 additions & 0 deletions src/features/ref_fixes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,13 @@ void __stdcall orig_glTexParameterf_mag_ui(int target_tex, int param_name, float
orig_glTexParameterf(target_tex,param_name,magfilter_ui);
}

/*
RefInMemory is a LoadLibrary() in-place Detour, for ref_gl.dll
*/
void refFixes_early(void) {
WriteE8Call(0x20066E75,&RefInMemory);
WriteByte(0x20066E7A,0x90);

orig_VID_LoadRefresh = DetourCreate((void*)0x20066E10,(void*)&my_VID_LoadRefresh,DETOUR_TYPE_JMP,5);
}
/*
Expand Down Expand Up @@ -515,10 +519,19 @@ int my_R_SetMode(void * deviceMode) {
return ret;
}
HMODULE (__stdcall *orig_LoadLibraryA)(LPCSTR lpLibFileName) = *(unsigned int*)0x20111178;

/*
RefInMemory is a LoadLibrary() in-place Detour, for ref_gl.dll
Allows to modify ref_gl.dll at before R_Init() returns.
*/
HMODULE __stdcall RefInMemory(LPCSTR lpLibFileName)
{
HMODULE ret = orig_LoadLibraryA(lpLibFileName);
if (ret) {
/*
Get the exact moment that hardware-changed new setup files are exec'ed (cpu_ vid_card different to config.cfg)
*/
WriteE8Call(0x3000FA26,&InitDefaults);
WriteByte(0x3000FA2B,0x90);
}
Expand Down
3 changes: 2 additions & 1 deletion src/features/scaled_font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ void my_Con_Init(void) {
//Called at end of QCommon_Init()
void scaledFont_apply(void) {

_sofbuddy_console_size = orig_Cvar_Get("_sofbuddy_console_size","0.35",CVAR_ARCHIVE,&consolesize_change);
//0.35 is nice value.
_sofbuddy_console_size = orig_Cvar_Get("_sofbuddy_console_size","0.5",CVAR_ARCHIVE,&consolesize_change);
//fontscale_change references a cvar, so order matters.
_sofbuddy_font_scale = orig_Cvar_Get("_sofbuddy_font_scale","1",CVAR_ARCHIVE,&fontscale_change);

Expand Down
16 changes: 13 additions & 3 deletions src/sof_buddy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ void my_orig_Qcommon_Init(int argc, char **argv);
qboolean my_Cbuf_AddLateCommands(void);

cvar_t *(*orig_Cvar_Get)(const char * name, const char * value, int flags, cvarcommand_t command) = 0x20021AE0;
void ( *orig_Com_Printf)(char * msg, ...) = 0x2001C6E0;
void ( *orig_Com_Printf)(char * msg, ...) = NULL;
void (*orig_Qcommon_Frame) (int msec) = 0x2001F720;

void (*orig_Qcommon_Init) (int argc, char **argv) = 0x2001F390;
Expand Down Expand Up @@ -114,11 +114,18 @@ void afterWsockInit(void)
causes a cascade of low performance cvars to kick in. (drivers/alldefs.cfg,geforce.cfg,cpu4.cfg,memory1.cfg)
which have very bad values in them.
they can become modified if new hardware values differ from config.cfg
they can become modified if new hardware values differ from config.cfg
The exact moment that hardware-changed new setup files are exec'ed (cpu_ vid_card different to config.cfg)
*/
void InitDefaults(void)
{
orig_Cmd_ExecuteString("exec drivers/highest.cfg\nset fx_maxdebrisonscreen 128\n");
orig_Cmd_ExecuteString("exec drivers/highest.cfg\n");
// fix 1024 high value of fx_maxdebrisonscreen, hurts cpu.
orig_Cmd_ExecuteString("set fx_maxdebrisonscreen 128\n");
// fix compression as default for some gpu.
orig_Cmd_ExecuteString("set r_isf GL_SOLID_FORMAT\n");
orig_Cmd_ExecuteString("set r_iaf GL_ALPHA_FORMAT\n");

PrintOut(PRINT_GOOD,"Fixed defaults\n");
}
Expand All @@ -141,6 +148,9 @@ void InitDefaults(void)
void my_FS_InitFilesystem(void) {
orig_FS_InitFilesystem();

//Allow PrintOut to use Com_Printf now.
orig_Com_Printf = 0x2001C6E0;

//Best (Earliest)(before exec config.cfg) place for cvar creation, if you want config.cfg induced triggering of modified events.
refFixes_apply();
#ifdef FEATURE_FONT_SCALING
Expand Down
3 changes: 1 addition & 2 deletions src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void PrintOut(int mode,char *msg,...)

#endif

#if 0
if ( orig_Com_Printf == NULL) return;
switch (mode) {
case PRINT_LOG :

Expand All @@ -121,7 +121,6 @@ void PrintOut(int mode,char *msg,...)
default :
orig_Com_Printf("%s",ac_tmp);
}
#endif

}

Expand Down

0 comments on commit d333b6d

Please sign in to comment.