Merge branch 'Saturn-Next' of ssh://github.com/Indev450/SRB2Kart-Saturn into Saturn-Next

This commit is contained in:
indev committed 2023-11-18 19:41:06 +03:00
commit 2f5b894c47
15 files changed
+412 -79

No files matched your search

+92 -1
View File
@@ -171,6 +171,8 @@ static textcmdtic_t *textcmds[TEXTCMD_HASH_SIZE] = {NULL};
consvar_t cv_showjoinaddress = {"showjoinaddress", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_shownodeip = {"showipinnodelist", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
static CV_PossibleValue_t playbackspeed_cons_t[] = {{1, "MIN"}, {10, "MAX"}, {0, NULL}};
consvar_t cv_playbackspeed = {"playbackspeed", "1", 0, playbackspeed_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
@@ -3346,7 +3348,7 @@ static void Command_Nodes(void)
{
CONS_Printf("%.2u: %*s", i, (int)maxlen, player_names[i]);
CONS_Printf(" - %.2d", playernode[i]);
if (I_GetNodeAddress && (address = I_GetNodeAddress(playernode[i])) != NULL)
if ((I_GetNodeAddress && (address = I_GetNodeAddress(playernode[i])) != NULL) && (cv_shownodeip.value))
CONS_Printf(" - %s", address);
if (IsPlayerAdmin(i))
@@ -3360,6 +3362,94 @@ static void Command_Nodes(void)
}
}
//Screw the base game nodes lets replace with listplayers instead.
static void Command_Listplayers(void)
{
const char *address;
int width = 0;
boolean admin;
boolean spectator;
/*
Mode of player status for an individual player (admin, spectator).
1 for admin
2 for spectator
4 for both
*/
int mode = 0;
INT32 totalplayers = 0;
const char *cc;
const char *pcc;
INT32 i;
int n;
for (i = 0; i < MAXPLAYERS; ++i)
if (playeringame[i])
{
n = strlen(player_names[i]);
if (n > width)
width = n;
if (mode != 7)
{
admin = IsPlayerAdmin(i);
spectator = players[i].spectator;
if (admin)
mode |= 1;
if (spectator)
mode |= 2;
if (admin && spectator)
mode |= 4;
}
}
for (i = 0; i < MAXPLAYERS; ++i)
if (playeringame[i])
{
admin = IsPlayerAdmin(i);
spectator = players[i].spectator;
if (admin)
cc = "\x85";/* red */
else if (spectator)
cc = "\x86";/* gray */
else
cc = "";
pcc = HU_SkinColorToConsoleColor(players[i].skincolor);
CONS_Printf("%.2d: ""%s""%-*s""\x80", i, pcc,width, player_names[i]);
if ((I_GetNodeAddress && (address = I_GetNodeAddress(playernode[i])) != NULL) && (cv_shownodeip.value))
CONS_Printf(" -- %s", address);
else/* print spacer */
{
/* ...but not if there's a crammed status and were admin */
if (mode != 7 || !admin)
CONS_Printf(" -- ");/* -- self */
}
if (admin)
CONS_Printf(M_GetText("%s"" (admin)"),cc);
if (spectator)
CONS_Printf(M_GetText("%s"" (spectator)"),cc);
CONS_Printf("\n");
totalplayers++;
}
if (totalplayers == 1)
CONS_Printf("\nThere is 1 player in the game.\n");
else
CONS_Printf("\nThere are %d players in the game.\n", totalplayers);
}
static void Command_Ban(void)
{
if (COM_Argc() < 2)
@@ -3925,6 +4015,7 @@ void D_ClientServerInit(void)
COM_AddCommand("reloadbans", Command_ReloadBan);
COM_AddCommand("connect", Command_connect);
COM_AddCommand("nodes", Command_Nodes);
COM_AddCommand("listplayers", Command_Listplayers);
#ifdef HAVE_CURL
COM_AddCommand("set_http_login", Command_set_http_login);
COM_AddCommand("list_http_logins", Command_list_http_logins);
+2
View File
@@ -515,6 +515,8 @@ extern consvar_t cv_kicktime;
extern consvar_t cv_showjoinaddress;
extern consvar_t cv_playbackspeed;
extern consvar_t cv_shownodeip;
#define BASEPACKETSIZE offsetof(doomdata_t, u)
#define FILETXHEADER offsetof(filetx_pak, data)
#define BASESERVERTICSSIZE offsetof(doomdata_t, u.serverpak.cmds[0])
+4 -1
View File
@@ -301,6 +301,8 @@ INT32 cv_debug;
consvar_t cv_usemouse = {"use_mouse", "Off", CV_SAVE|CV_CALL,usemouse_cons_t, I_StartupMouse, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_usemouse2 = {"use_mouse2", "Off", CV_SAVE|CV_CALL,usemouse_cons_t, I_StartupMouse2, 0, NULL, NULL, 0, 0, NULL};
//WTF
consvar_t cv_mouseturn = {"mouseturn", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
#if defined(HAVE_SDL) || defined(_WINDOWS) //joystick 1 and 2
consvar_t cv_usejoystick = {"use_joystick", "1", CV_SAVE|CV_CALL, usejoystick_cons_t,
@@ -509,7 +511,7 @@ static CV_PossibleValue_t skinselectspin_cons_t[] = {
consvar_t cv_skinselectspin = {"skinselectspin", "5", CV_SAVE, skinselectspin_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
static CV_PossibleValue_t perfstats_cons_t[] = {
{0, "Off"}, {1, "Rendering"}, {2, "Logic"}, {3, "ThinkFrame"}, {0, NULL}};
{0, "Off"}, {1, "Rendering"}, {2, "Logic"}, {3, "ThinkFrame"}, {4, "PreThinkFrame"}, {5, "PostThinkFrame"}, {0, NULL}};
consvar_t cv_perfstats = {"perfstats", "Off", CV_CALL, perfstats_cons_t, PS_PerfStats_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_ps_thinkframe_page = {"ps_thinkframe_page", "1", CV_CALL, CV_Natural, PS_ThinkFrame_Page_OnChange, 0, NULL, NULL, 0, 0, NULL};
@@ -774,6 +776,7 @@ void D_RegisterServerCommands(void)
CV_RegisterVar(&cv_joinnextround);
#endif
CV_RegisterVar(&cv_showjoinaddress);
CV_RegisterVar(&cv_shownodeip);
CV_RegisterVar(&cv_blamecfail);
#endif
+2
View File
@@ -41,6 +41,8 @@ extern consvar_t cv_splitplayers;
extern consvar_t cv_seenames, cv_allowseenames;
#endif
extern consvar_t cv_usemouse;
//WTF
extern consvar_t cv_mouseturn;
extern consvar_t cv_usejoystick;
extern consvar_t cv_usejoystick2;
extern consvar_t cv_usejoystick3;
+1 -1
View File
@@ -169,7 +169,7 @@ void I_SetMusicVolume(UINT8 volume)
(void)volume;
}
boolean I_SetSongTrack(int track)
boolean I_SetSongTrack(INT32 track)
{
(void)track;
return false;
+2 -2
View File
@@ -1427,9 +1427,9 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
side += ((axis * sidemove[0]) >> 10);
}
// Specator mouse turning
if (player->spectator)
if (player->spectator || cv_mouseturn.value)
{
//THIS WORKS WTF????????
cmd->angleturn = (INT16)(cmd->angleturn - ((mousex*(encoremode ? -1 : 1)*8)));
cmd->driftturn = (INT16)(cmd->driftturn - ((mousex*(encoremode ? -1 : 1)*8)));
}
+9 -5
View File
@@ -1366,15 +1366,19 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
angle_t sliptideroll = 0;
if (spr->mobj->player)
sliptideroll = ((cv_sloperoll.value) ? spr->mobj->player->sliproll : 0);
sliptideroll = ((cv_sloperoll.value && cv_sliptideroll.value) ? spr->mobj->player->sliproll : 0);
if ((spr->mobj->rollangle)||sliptideroll)
if ((spr->mobj->rollangle)||(sliptideroll && cv_sliptideroll.value))
{
angle_t rollang = 0;
rollfactor = ((spr->mobj->rollmodel == true) ? 1 : 0);
if (spr->mobj->player)
rollang = (spr->mobj->rollangle*rollfactor) + (sliptideroll*spr->mobj->player->sliptidemem);
if (spr->mobj->player){
if (sliptideroll && cv_sliptideroll.value)
rollang = (spr->mobj->rollangle*rollfactor) + (sliptideroll*spr->mobj->player->sliptidemem);
else
rollang = (spr->mobj->rollangle*rollfactor);
}
else
rollang = (spr->mobj->rollangle*rollfactor);
@@ -1423,7 +1427,7 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
HWD.pfnSetShader(4); // model shader
{
float this_scale = FIXED_TO_FLOAT(interp.scale);
float this_scale = FIXED_TO_FLOAT(interp.scale);
float xs = this_scale * FIXED_TO_FLOAT(interp.spritexscale);
float ys = this_scale * FIXED_TO_FLOAT(interp.spriteyscale);
+3
View File
@@ -720,6 +720,9 @@ void K_RegisterKartStuff(void)
CV_RegisterVar(&cv_stagetitle);
CV_RegisterVar(&cv_lessflicker);
CV_RegisterVar(&cv_mouseturn);
}
//}
+53 -22
View File
@@ -430,6 +430,9 @@ void LUAh_PlayerJoin(int playernum)
void LUAh_PreThinkFrame(void)
{
hook_p hookp;
// variables used by perf stats
int hook_index = 0;
precise_t time_taken = 0;
if (!gL || !(hooksAvailable[hook_PreThinkFrame/8] & (1<<(hook_PreThinkFrame%8))))
return;
@@ -437,19 +440,32 @@ void LUAh_PreThinkFrame(void)
for (hookp = roothook; hookp; hookp = hookp->next)
{
if (hookp->type != hook_PreThinkFrame)
continue;
lua_pushfstring(gL, FMT_HOOKID, hookp->id);
lua_gettable(gL, LUA_REGISTRYINDEX);
if (lua_pcall(gL, 0, 0, 1)) {
if (!hookp->error || cv_debug & DBG_LUA)
CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1));
lua_pop(gL, 1);
hookp->error = true;
if (hookp->type == hook_PreThinkFrame)
{
if (cv_perfstats.value == 4)
time_taken = I_GetPreciseTime();
lua_pushfstring(gL, FMT_HOOKID, hookp->id);
lua_gettable(gL, LUA_REGISTRYINDEX);
if (lua_pcall(gL, 0, 0, 1)) {
if (!hookp->error || cv_debug & DBG_LUA)
CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1));
lua_pop(gL, 1);
hookp->error = true;
}
if (cv_perfstats.value == 4)
{
lua_Debug ar;
time_taken = I_GetPreciseTime() - time_taken;
// we need the function, let's just retrieve it again
lua_pushfstring(gL, FMT_HOOKID, hookp->id);
lua_gettable(gL, LUA_REGISTRYINDEX);
lua_getinfo(gL, ">S", &ar);
PS_SetPreThinkFrameHookInfo(hook_index, time_taken, ar.short_src);
hook_index++;
}
}
}
}
lua_pop(gL, 1); // Pop error handler
}
@@ -498,6 +514,9 @@ void LUAh_ThinkFrame(void)
void LUAh_PostThinkFrame(void)
{
hook_p hookp;
// variables used by perf stats
int hook_index = 0;
precise_t time_taken = 0;
if (!gL || !(hooksAvailable[hook_PostThinkFrame/8] & (1<<(hook_PostThinkFrame%8))))
return;
@@ -505,19 +524,31 @@ void LUAh_PostThinkFrame(void)
for (hookp = roothook; hookp; hookp = hookp->next)
{
if (hookp->type != hook_PostThinkFrame)
continue;
lua_pushfstring(gL, FMT_HOOKID, hookp->id);
lua_gettable(gL, LUA_REGISTRYINDEX);
if (lua_pcall(gL, 0, 0, 1)) {
if (!hookp->error || cv_debug & DBG_LUA)
CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1));
lua_pop(gL, 1);
hookp->error = true;
if (hookp->type == hook_PostThinkFrame)
{
if (cv_perfstats.value == 5)
time_taken = I_GetPreciseTime();
lua_pushfstring(gL, FMT_HOOKID, hookp->id);
lua_gettable(gL, LUA_REGISTRYINDEX);
if (lua_pcall(gL, 0, 0, 1)) {
if (!hookp->error || cv_debug & DBG_LUA)
CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1));
lua_pop(gL, 1);
hookp->error = true;
}
if (cv_perfstats.value == 5)
{
lua_Debug ar;
time_taken = I_GetPreciseTime() - time_taken;
// we need the function, let's just retrieve it again
lua_pushfstring(gL, FMT_HOOKID, hookp->id);
lua_gettable(gL, LUA_REGISTRYINDEX);
lua_getinfo(gL, ">S", &ar);
PS_SetPostThinkFrameHookInfo(hook_index, time_taken, ar.short_src);
hook_index++;
}
}
}
lua_pop(gL, 1); // Pop error handler
}
+52 -14
View File
@@ -1166,9 +1166,11 @@ static menuitem_t OP_ControlsMenu[] =
{IT_CALL | IT_STRING, NULL, "Player 3 Controls...", &M_Setup3PControlsMenu, 30},
{IT_CALL | IT_STRING, NULL, "Player 4 Controls...", &M_Setup4PControlsMenu, 40},
{IT_SUBMENU | IT_STRING, NULL, "Mouse Options...", &OP_MouseOptionsDef, 60},
{IT_STRING | IT_CVAR, NULL, "Controls per key", &cv_controlperkey, 60},
{IT_STRING | IT_CVAR, NULL, "Digital turn easing", &cv_turnsmooth, 70},
{IT_STRING | IT_CVAR, NULL, "Controls per key", &cv_controlperkey, 80},
{IT_STRING | IT_CVAR, NULL, "Digital turn easing", &cv_turnsmooth, 90},
};
static const char* OP_ControlsTooltips[] =
@@ -1179,6 +1181,9 @@ static const char* OP_ControlsTooltips[] =
"Setup player 3 controls.",
"Setup player 4 controls.",
"Options for mouse control.",
"Allowed amount of controls per key.",
"Turn smoothing for non-analog turning.",
@@ -1298,22 +1303,34 @@ static menuitem_t OP_JoystickSetMenu[] =
{IT_CALL | IT_NOTHING, "", NULL, M_AssignJoystick, (LINEHEIGHT*8)+5},
};
/*static menuitem_t OP_MouseOptionsMenu[] =
//WTF
static menuitem_t OP_MouseOptionsMenu[] =
{
{IT_STRING | IT_CVAR, NULL, "Use Mouse", &cv_usemouse, 10},
{IT_STRING | IT_CVAR, NULL, "First-Person MouseLook", &cv_alwaysfreelook, 30},
{IT_STRING | IT_CVAR, NULL, "Third-Person MouseLook", &cv_chasefreelook, 40},
{IT_STRING | IT_CVAR, NULL, "Mouse Move", &cv_mousemove, 50},
{IT_STRING | IT_CVAR, NULL, "Invert Mouse", &cv_invertmouse, 60},
//{IT_STRING | IT_CVAR, NULL, "First-Person MouseLook", &cv_alwaysfreelook, 30},
//{IT_STRING | IT_CVAR, NULL, "Third-Person MouseLook", &cv_chasefreelook, 40},
{IT_STRING | IT_CVAR, NULL, "Mouse Turning", &cv_mouseturn, 20},
{IT_STRING | IT_CVAR, NULL, "Invert Mouse", &cv_invertmouse, 30},
{IT_STRING | IT_CVAR | IT_CV_SLIDER,
NULL, "Mouse X Speed", &cv_mousesens, 70},
NULL, "Mouse X Speed", &cv_mousesens, 40},
{IT_STRING | IT_CVAR | IT_CV_SLIDER,
NULL, "Mouse Y Speed", &cv_mouseysens, 80},
NULL, "Mouse Y Speed", &cv_mouseysens, 50},
};
static menuitem_t OP_Mouse2OptionsMenu[] =
static const char* OP_MouseTooltips[] =
{
"Enable the use of the mouse.",
"Turn using the mouse.",
"Invert mouse movements.",
"Mouse horizontal sensitivity.",
"Mouse vertical sensitivity.",
};
/*static menuitem_t OP_Mouse2OptionsMenu[] =
{
{IT_STRING | IT_CVAR, NULL, "Use Mouse 2", &cv_usemouse2, 10},
{IT_STRING | IT_CVAR, NULL, "Second Mouse Serial Port",
@@ -1732,8 +1749,10 @@ static menuitem_t OP_ChatOptionsMenu[] =
{IT_STRING | IT_CVAR, NULL, "Max Chat Messages", &cv_chatlogsize, 80},
{IT_STRING | IT_CVAR, NULL, "Local ping display", &cv_showping, 100}, // shows ping next to framerate if we want to.
{IT_STRING | IT_CVAR, NULL, "Ping measurement", &cv_pingmeasurement, 110},
{IT_STRING | IT_CVAR, NULL, "Ping icon", &cv_pingicon, 120},
{IT_STRING | IT_CVAR, NULL, "Ping measurement", &cv_pingmeasurement, 110},
{IT_STRING | IT_CVAR, NULL, "Ping icon", &cv_pingicon, 120},
{IT_STRING | IT_CVAR, NULL, "Show IP addresses in playerlist", &cv_shownodeip, 140},
};
static const char* OP_ChatOptionsTooltips[] =
@@ -1748,6 +1767,7 @@ static const char* OP_ChatOptionsTooltips[] =
"Show player ping.",
"Measurement used for ping.",
"Visibility of ping icon.",
"Should Player IP addresses be printed when using\nthe nodes or listplayers command?",
};
static menuitem_t OP_GameOptionsMenu[] =
@@ -2648,6 +2668,8 @@ menu_t OP_MainDef =
};
menu_t OP_ControlsDef = DEFAULTMENUSTYLE("M_CONTRO", OP_ControlsMenu, &OP_MainDef, 60, 30);
//WTF
menu_t OP_MouseOptionsDef = DEFAULTMENUSTYLE("M_CONTRO", OP_MouseOptionsMenu, &OP_ControlsDef, 60, 30);
menu_t OP_AllControlsDef = CONTROLMENUSTYLE(OP_AllControlsMenu, &OP_ControlsDef);
menu_t OP_Joystick1Def = DEFAULTMENUSTYLE("M_CONTRO", OP_Joystick1Menu, &OP_AllControlsDef, 60, 30);
menu_t OP_Joystick2Def = DEFAULTMENUSTYLE("M_CONTRO", OP_Joystick2Menu, &OP_AllControlsDef, 60, 30);
@@ -4042,7 +4064,7 @@ void M_StartControlPanel(void)
Dummymenuplayer_OnChange();
if (server)
if ((server || IsPlayerAdmin(consoleplayer)))
{
MPauseMenu[mpause_switchmap].status = IT_STRING | IT_CALL;
MPauseMenu[mpause_addons].status = IT_STRING | IT_CALL;
@@ -4866,6 +4888,15 @@ static void M_DrawGenericMenu(void)
}
}
if (currentMenu == &OP_MouseOptionsDef)
{
if (!(OP_MouseTooltips[itemOn] == NULL))
{
M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_MouseTooltips[itemOn], 30, coolalphatimer);
if (coolalphatimer > 0 && interpTimerHackAllow)
coolalphatimer--;
}
}
if (currentMenu == &OP_VideoOptionsDef)
{
@@ -6124,6 +6155,8 @@ static void M_AddonsClearName(INT32 choice)
M_StopMessage(choice);
}
int errorshitspam = 0; // prevent the warning screen from crapping itself when errors get spammed lmao
// returns whether to do message draw
static boolean M_AddonsRefresh(void)
{
@@ -6152,10 +6185,11 @@ static boolean M_AddonsRefresh(void)
else
message = va("%c%s\x80\nA file was not loaded.\nCheck the console log for more information.\n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), refreshdirname);
}
else if (refreshdirmenu & (REFRESHDIR_WARNING|REFRESHDIR_ERROR))
else if ((refreshdirmenu & (REFRESHDIR_WARNING | REFRESHDIR_ERROR)) && !errorshitspam)
{
S_StartSound(NULL, sfx_s224);
message = va("%c%s\x80\nA file was loaded with %s.\nCheck the console log for more information.\n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), refreshdirname, ((refreshdirmenu & REFRESHDIR_ERROR) ? "errors" : "warnings"));
errorshitspam = 1; // you already said that shit
}
else if (majormods && !prevmajormods)
{
@@ -6498,12 +6532,16 @@ static void M_HandleAddons(INT32 choice)
if (DumbStartsWith("KC_", dirmenu[dir_on[menudepthleft]]+DIR_STRING) || DumbStartsWith("kc_", dirmenu[dir_on[menudepthleft]]+DIR_STRING)) {
M_StartMessage(va("%c%s\x80\nYou are loading a local skin.\nLocal skins will not be usable\nafter going back from\nthe title screen.\n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), dirmenu[dir_on[menudepthleft]]+DIR_STRING),NULL,MM_NOTHING);
COM_BufAddText(va("addskins \"%s%s\"", menupath, dirmenu[dir_on[menudepthleft]]+DIR_STRING));
errorshitspam = 0; // reset it so it can show the warning screen again lmao
}
else
S_StartSound(NULL, sfx_s26d);
}
else
{
COM_BufAddText(va("addfile \"%s%s\"", menupath, dirmenu[dir_on[menudepthleft]]+DIR_STRING));
errorshitspam = 0; // reset it so it can show the warning screen again lmao
}
break;
default:
S_StartSound(NULL, sfx_s26d);
+174 -27
View File
@@ -63,7 +63,10 @@ static ps_metric_t ps_removecount = {0};
ps_metric_t ps_checkposition_calls = {0};
ps_metric_t ps_lua_prethinkframe_time = {0};
ps_metric_t ps_lua_thinkframe_time = {0};
ps_metric_t ps_lua_postthinkframe_time = {0};
ps_metric_t ps_lua_mobjhooks = {0};
ps_metric_t ps_otherlogictime = {0};
@@ -156,7 +159,9 @@ perfstatrow_t gamelogic_rows[] = {
{" mobjs ", " Mobjs: ", &ps_thlist_times[THINK_MOBJ], PS_TIME|PS_LEVEL},
{" dynslop", " Dynamic slopes: ", &ps_thlist_times[THINK_DYNSLOPE], PS_TIME|PS_LEVEL},
{" precip ", " Precipitation: ", &ps_thlist_times[THINK_PRECIP], PS_TIME|PS_LEVEL},*/
{" lprethinkf", " LUAh_PreThinkFrame:", &ps_lua_prethinkframe_time, PS_TIME|PS_LEVEL},
{" lthinkf", " LUAh_ThinkFrame:", &ps_lua_thinkframe_time, PS_TIME|PS_LEVEL},
{" lpostthinkf", " LUAh_PostThinkFrame:", &ps_lua_postthinkframe_time, PS_TIME|PS_LEVEL},
{" other ", " Other: ", &ps_otherlogictime, PS_TIME|PS_LEVEL},
{0}
};
@@ -189,10 +194,43 @@ int ps_frame_index = 0;
int ps_tick_index = 0;
// dynamically allocated resizeable array for thinkframe hook stats
ps_hookinfo_t *prethinkframe_hooks = NULL;
int prethinkframe_hooks_length = 0;
int prethinkframe_hooks_capacity = 16;
ps_hookinfo_t *thinkframe_hooks = NULL;
int thinkframe_hooks_length = 0;
int thinkframe_hooks_capacity = 16;
ps_hookinfo_t *postthinkframe_hooks = NULL;
int postthinkframe_hooks_length = 0;
int postthinkframe_hooks_capacity = 16;
void PS_SetPreThinkFrameHookInfo(int index, precise_t time_taken, char* short_src)
{
if (!prethinkframe_hooks)
{
// array needs to be initialized
prethinkframe_hooks = Z_Calloc(sizeof(ps_hookinfo_t) * prethinkframe_hooks_capacity, PU_STATIC, NULL);
}
if (index >= prethinkframe_hooks_capacity)
{
// array needs more space, realloc with double size
int new_capacity = prethinkframe_hooks_capacity * 2;
prethinkframe_hooks = Z_Realloc(prethinkframe_hooks,
sizeof(ps_hookinfo_t) * new_capacity, PU_STATIC, NULL);
// initialize new memory with zeros so the pointers in the structs are null
memset(&prethinkframe_hooks[prethinkframe_hooks_capacity], 0,
sizeof(ps_hookinfo_t) * prethinkframe_hooks_capacity);
prethinkframe_hooks_capacity = new_capacity;
}
prethinkframe_hooks[index].time_taken.value.p = time_taken;
memcpy(prethinkframe_hooks[index].short_src, short_src, LUA_IDSIZE * sizeof(char));
// since the values are set sequentially from begin to end, the last call should leave
// the correct value to this variable
prethinkframe_hooks_length = index + 1;
}
void PS_SetThinkFrameHookInfo(int index, precise_t time_taken, char* short_src)
{
if (!thinkframe_hooks)
@@ -218,6 +256,33 @@ void PS_SetThinkFrameHookInfo(int index, precise_t time_taken, char* short_src)
thinkframe_hooks_length = index + 1;
}
void PS_SetPostThinkFrameHookInfo(int index, precise_t time_taken, char* short_src)
{
if (!postthinkframe_hooks)
{
// array needs to be initialized
postthinkframe_hooks = Z_Calloc(sizeof(ps_hookinfo_t) * postthinkframe_hooks_capacity, PU_STATIC, NULL);
}
if (index >= postthinkframe_hooks_capacity)
{
// array needs more space, realloc with double size
int new_capacity = postthinkframe_hooks_capacity * 2;
postthinkframe_hooks = Z_Realloc(postthinkframe_hooks,
sizeof(ps_hookinfo_t) * new_capacity, PU_STATIC, NULL);
// initialize new memory with zeros so the pointers in the structs are null
memset(&postthinkframe_hooks[postthinkframe_hooks_capacity], 0,
sizeof(ps_hookinfo_t) * postthinkframe_hooks_capacity);
postthinkframe_hooks_capacity = new_capacity;
}
postthinkframe_hooks[index].time_taken.value.p = time_taken;
memcpy(postthinkframe_hooks[index].short_src, short_src, LUA_IDSIZE * sizeof(char));
// since the values are set sequentially from begin to end, the last call should leave
// the correct value to this variable
postthinkframe_hooks_length = index + 1;
}
static boolean PS_HighResolution(void)
{
return (vid.width >= 640 && vid.height >= 400);
@@ -578,7 +643,11 @@ void PS_UpdateTickStats(void)
ps_tictime.value.p -
ps_playerthink_time.value.p -
ps_thinkertime.value.p -
ps_lua_thinkframe_time.value.p;
ps_lua_prethinkframe_time.value.p -
ps_lua_thinkframe_time.value.p -
ps_lua_postthinkframe_time.value.p;
PS_CountThinkers();
}
@@ -590,21 +659,37 @@ void PS_UpdateTickStats(void)
PS_UpdateRowHistories(misc_calls_rows, false);
}
}
if (cv_perfstats.value == 3 && cv_ps_samplesize.value > 1 && PS_IsLevelActive())
if (cv_ps_samplesize.value > 1)
{
int i;
for (i = 0; i < thinkframe_hooks_length; i++)
if(cv_perfstats.value >= 3 && PS_IsLevelActive())
{
PS_UpdateMetricHistory(&thinkframe_hooks[i].time_taken, true, false, false);
int i;
if (cv_perfstats.value == 3)
{
for (i = 0; i < thinkframe_hooks_length; i++)
PS_UpdateMetricHistory(&thinkframe_hooks[i].time_taken, true, false, false);
}
else if (cv_perfstats.value == 4)
{
for (i = 0; i < prethinkframe_hooks_length; i++)
PS_UpdateMetricHistory(&prethinkframe_hooks[i].time_taken, true, false, false);
}
else if (cv_perfstats.value == 5)
{
for (i = 0; i < postthinkframe_hooks_length; i++)
PS_UpdateMetricHistory(&postthinkframe_hooks[i].time_taken, true, false, false);
}
}
}
if (cv_perfstats.value && cv_ps_samplesize.value > 1)
{
ps_tick_index++;
if (ps_tick_index >= cv_ps_samplesize.value)
ps_tick_index = 0;
if (ps_tick_samples_left)
ps_tick_samples_left--;
if (cv_perfstats.value)
{
ps_tick_index++;
if (ps_tick_index >= cv_ps_samplesize.value)
ps_tick_index = 0;
if (ps_tick_samples_left)
ps_tick_samples_left--;
}
}
}
@@ -624,7 +709,7 @@ static void PS_DrawDescriptorHeader(void)
int samples_left = max(ps_frame_samples_left, ps_tick_samples_left);
int x, y;
if (cv_perfstats.value == 3)
if (cv_perfstats.value >= 3)
{
x = 2;
y = 0;
@@ -717,21 +802,20 @@ static void PS_DrawGameLogicStats(void)
#define WIDTH 106
#define HEIGHT 4
#define MAX_X 214
#define MAX_Y 192
#define MAX_Y 182
#define START_X 2
#define START_Y 4
#define PAGE_ENTRIES ((MAX_Y - START_Y) / HEIGHT)
static void PS_DrawThinkFrameStats(void)
static void draw_think_frame_stats(int hook_length, ps_hookinfo_t *hook)
{
char s[100];
int i;
int maxpage = thinkframe_hooks_length/PAGE_ENTRIES + 1;
int page = max(1, min(cv_ps_thinkframe_page.value, maxpage));
int pagestart = min((page - 1)*PAGE_ENTRIES, thinkframe_hooks_length);
int pageend = min(pagestart + PAGE_ENTRIES, thinkframe_hooks_length);
int maxpage = 0;
int page = 0;
int pagestart = 0;
int pageend = 0;
// text writing position
int x = START_X;
int y = START_Y;
@@ -741,19 +825,44 @@ static void PS_DrawThinkFrameStats(void)
last_mod_name[0] = '\0';
INT32 total = 0;
//Decide page length based and drawn text on choosen thinker type
if (cv_perfstats.value == 3){
maxpage = thinkframe_hooks_length/PAGE_ENTRIES + 1;
page = max(1, min(cv_ps_thinkframe_page.value, maxpage));
pagestart = min((page - 1)*PAGE_ENTRIES, thinkframe_hooks_length);
pageend = min(pagestart + PAGE_ENTRIES, thinkframe_hooks_length);
V_DrawSmallString(MAX_X-50, MAX_Y+2*HEIGHT, V_MONOSPACE | V_GREENMAP, "ThinkFrame");
}
else if (cv_perfstats.value == 4){
maxpage = prethinkframe_hooks_length/PAGE_ENTRIES + 1;
page = max(1, min(cv_ps_thinkframe_page.value, maxpage));
pagestart = min((page - 1)*PAGE_ENTRIES, prethinkframe_hooks_length);
pageend = min(pagestart + PAGE_ENTRIES, prethinkframe_hooks_length);
V_DrawSmallString(MAX_X-60, MAX_Y+2*HEIGHT, V_MONOSPACE | V_GREENMAP, "PreThinkFrame");
}
else if (cv_perfstats.value == 5){
maxpage = postthinkframe_hooks_length/PAGE_ENTRIES + 1;
page = max(1, min(cv_ps_thinkframe_page.value, maxpage));
pagestart = min((page - 1)*PAGE_ENTRIES, postthinkframe_hooks_length);
pageend = min(pagestart + PAGE_ENTRIES, postthinkframe_hooks_length);
V_DrawSmallString(MAX_X-65, MAX_Y+2*HEIGHT, V_MONOSPACE | V_GREENMAP, "PostThinkFrame");
}
PS_DrawDescriptorHeader();
for (i = 0; i < thinkframe_hooks_length; i++)
for (i = 0; i < hook_length; i++)
{
#define NEXT_ROW() y += HEIGHT;
INT32 value = PS_GetMetricScreenValue(&thinkframe_hooks[i].time_taken, true);
INT32 value = PS_GetMetricScreenValue(&hook[i].time_taken, true);
total += value;
if (i < pagestart || i >= pageend) continue;
char* str = thinkframe_hooks[i].short_src;
char* str = hook[i].short_src;
char* tempstr = tempbuffer;
int len = (int)strlen(str);
char* str_ptr;
@@ -808,6 +917,8 @@ static void PS_DrawThinkFrameStats(void)
snprintf(s, sizeof s - 1, "PAGE %d", page);
V_DrawSmallString(START_X, MAX_Y+2*HEIGHT, V_MONOSPACE | V_GREENMAP, s);
}
}
void PS_ThinkFrame_Page_OnChange(void)
@@ -828,6 +939,24 @@ void PS_ThinkFrame_Page_OnChange(void)
#undef PAGE_ENTRIES
static void PS_DrawPreThinkFrameStats(void)
{
draw_think_frame_stats(prethinkframe_hooks_length, prethinkframe_hooks);
}
static void PS_DrawThinkFrameStats(void)
{
draw_think_frame_stats(thinkframe_hooks_length, thinkframe_hooks);
}
static void PS_DrawPostThinkFrameStats(void)
{
draw_think_frame_stats(postthinkframe_hooks_length, postthinkframe_hooks);
}
void M_DrawPerfStats(void)
{
if (cv_perfstats.value == 1) // rendering
@@ -841,7 +970,7 @@ void M_DrawPerfStats(void)
// tics when frame skips happen
PS_DrawGameLogicStats();
}
else if (cv_perfstats.value == 3) // lua thinkframe
else if (cv_perfstats.value >= 3) // lua thinkframe
{
if (!PS_IsLevelActive())
return;
@@ -850,13 +979,23 @@ void M_DrawPerfStats(void)
// Low resolutions can't really use V_DrawSmallString that is used by thinkframe stats.
// A low-res version using V_DrawThinString could be implemented,
// but it would have much less space for information.
V_DrawThinString(80, 92, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, "Perfstats 3 is not available");
V_DrawThinString(80, 92, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, "Lua Perfstats is not available");
V_DrawThinString(80, 100, V_MONOSPACE | V_ALLOWLOWERCASE | V_YELLOWMAP, "for resolutions below 640x400.");
return;
}
else
if (cv_perfstats.value == 3)
{
PS_DrawThinkFrameStats();
}
else if (cv_perfstats.value == 4)
{
PS_DrawPreThinkFrameStats();
}
else if (cv_perfstats.value == 5)
{
PS_DrawPostThinkFrameStats();
}
}
}
@@ -867,10 +1006,18 @@ static void PS_ClearHistory(void)
Z_FreeTags(PU_PERFSTATS, PU_PERFSTATS);
// thinkframe hook metric history pointers need to be cleared manually
for (i = 0; i < prethinkframe_hooks_length; i++)
{
prethinkframe_hooks[i].time_taken.history = NULL;
}
for (i = 0; i < thinkframe_hooks_length; i++)
{
thinkframe_hooks[i].time_taken.history = NULL;
}
for (i = 0; i < postthinkframe_hooks_length; i++)
{
postthinkframe_hooks[i].time_taken.history = NULL;
}
ps_frame_index = ps_tick_index = 0;
// PS_UpdateMetricHistory will set these correctly when it runs
+5
View File
@@ -44,12 +44,17 @@ extern ps_metric_t ps_thlist_times[];
extern ps_metric_t ps_checkposition_calls;
extern ps_metric_t ps_lua_prethinkframe_time;
extern ps_metric_t ps_lua_thinkframe_time;
extern ps_metric_t ps_lua_postthinkframe_time;
extern ps_metric_t ps_lua_mobjhooks;
extern ps_metric_t ps_otherlogictime;
void PS_SetPreThinkFrameHookInfo(int index, precise_t time_taken, char* short_src);
void PS_SetThinkFrameHookInfo(int index, precise_t time_taken, char* short_src);
void PS_SetPostThinkFrameHookInfo(int index, precise_t time_taken, char* short_src);
void PS_UpdateTickStats(void);
+7
View File
@@ -662,7 +662,10 @@ void P_Ticker(boolean run)
ps_checkposition_calls.value.i = 0;
#ifdef HAVE_BLUA
PS_START_TIMING(ps_lua_prethinkframe_time);
LUAh_PreThinkFrame();
PS_STOP_TIMING(ps_lua_prethinkframe_time);
#endif
PS_START_TIMING(ps_playerthink_time);
@@ -823,7 +826,11 @@ void P_Ticker(boolean run)
D_MapChange(gamemap, gametype, encoremode, true, 0, false, false);
#ifdef HAVE_BLUA
PS_START_TIMING(ps_lua_postthinkframe_time);
LUAh_PostThinkFrame();
PS_STOP_TIMING(ps_lua_postthinkframe_time);
#endif
}
+5 -5
View File
@@ -696,8 +696,8 @@ static void mix_gme(void *udata, Uint8 *stream, int len)
music_volume = 18;
// apply volume to stream
for (i = 0, p = (short *)stream; i < len/2; i++, p++)
*p = ((INT32)*p) * (music_volume*internal_volume/100)*2 / 40;
for (i = 0, p = (short *)stream; i < len / 2; i++, p++)
*p = ((INT32)*p) * music_volume * internal_volume / 100 / 20;
}
#endif
@@ -721,8 +721,8 @@ static void mix_openmpt(void *udata, Uint8 *stream, int len)
music_volume = 18;
// apply volume to stream
for (i = 0, p = (short *)stream; i < len/2; i++, p++)
*p = ((INT32)*p) * (music_volume*internal_volume/100)*2 / 40;
for (i = 0, p = (short *)stream; i < len / 2; i++, p++)
*p = ((INT32)*p) * music_volume * internal_volume / 100 / 20;
}
#endif
@@ -1375,7 +1375,7 @@ void I_SetMusicVolume(UINT8 volume)
Mix_VolumeMusic(get_real_volume(music_volume));
}
boolean I_SetSongTrack(int track)
boolean I_SetSongTrack(INT32 track)
{
#ifdef HAVE_LIBGME
+1 -1
View File
@@ -1476,7 +1476,7 @@ void I_SetMusicVolume(UINT8 volume)
(void)volume;
}
boolean I_SetSongTrack(int track)
boolean I_SetSongTrack(INT32 track)
{
(void)track;
return false;