Merge branch 'Saturn' into snowy

This commit is contained in:
indev authored and GitHub committed 2023-08-29 10:33:10 +03:00
commit 00f09421b8
33 files changed
+1081 -674

No files matched your search

+1 -1
View File
@@ -22,8 +22,8 @@
- Configurable timeout for waiting to join a full server (in vanilla this is capped to 5 minutes before it boots you out)
- Characters now spin in skin selection menu (configurable)
- HTTP Addon download speed has been raised dramatically (configurable with "downloadspeed" command)
- Zone memory allocations have been rewritten, speeds up some map loading, and may improve performance on busy maps
- HWR Drawnodes have been refactored, this should fix a few rare crashes esp in regards to OpenGL Visportals
- The Position Number in the corner is alot smaller now (half the size!)
- MSAA and A2C Antialiasing support (Configurable in renderer.txt file)
## Performance / Debugging
+35 -1
View File
@@ -634,10 +634,44 @@ static void COM_ExecuteString(char *ptext)
static void COM_Alias_f(void)
{
cmdalias_t *a;
const char *alias_format = "\x87%-8s:\x80 %s\n";
int argc = COM_Argc();
if (COM_Argc() < 3)
if (argc == 2)
{
const char *begin = COM_Argv(1);
size_t szBegin = strlen(begin);
/* Display all aliases that start with `begin`. */
CONS_Printf(M_GetText("All aliases that start with \x87'%s'\x80 are:\n"), begin);
int count = 0;
for (cmdalias_t *head = com_alias; head->next != NULL; head = head->next)
{
if (strncmp(begin, head->name, szBegin) == 0)
{
CONS_Printf(alias_format, head->name, head->value);
count++;
}
}
if (count == 0)
{
CONS_Printf(M_GetText("There are none.\n"));
}
return;
}
else if (argc < 3)
{
/* Display alias subtext, show all aliases. */
CONS_Printf(M_GetText("alias <name> <command>: create a shortcut command that executes other command(s)\n"));
for (cmdalias_t *head = com_alias; head->next != NULL; head = head->next)
{
CONS_Printf(alias_format, head->name, head->value);
}
return;
}
+11
View File
@@ -957,9 +957,12 @@ static boolean AddIWAD(void)
}
}
boolean found_extra_kart;
static void IdentifyVersion(void)
{
const char *srb2waddir = NULL;
found_extra_kart = false;
#if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) || defined (HAVE_SDL)
// change to the directory where 'srb2.srb' is found
@@ -1012,6 +1015,11 @@ static void IdentifyVersion(void)
#ifdef USE_PATCH_KART
D_AddFile(va(pandf,srb2waddir,"patch.kart"), startupwadfiles);
#endif
// completely optional
if (FIL_ReadFileOK(va(pandf,srb2waddir,"extra.kart"))) {
D_AddFile(va(pandf,srb2waddir,"extra.kart"), startupwadfiles);
found_extra_kart = true;
}
#if !defined (HAVE_SDL) || defined (HAVE_MIXER)
#define MUSICTEST(str) \
@@ -1337,6 +1345,9 @@ void D_SRB2Main(void)
#endif //ifndef DEVELOP
if (found_extra_kart) // found the funny, add it in!
mainwads++;
//
// search for maps
//
+2
View File
@@ -25,6 +25,8 @@ extern boolean usehome; //Alam: which path?
extern const char *pandf; //Alam: how to path?
extern char srb2path[256]; //Alam: SRB2's Home
extern boolean found_extra_kart; // for use in k_kart.c
// the infinite loop of D_SRB2Loop() called from win_main for windows version
void D_SRB2Loop(void) FUNCNORETURN;
+117
View File
@@ -190,6 +190,9 @@ static void Command_ShowTime_f(void);
static void Command_Isgamemodified_f(void);
static void Command_Cheats_f(void);
static void Command_ListSkins(void);
#ifdef _DEBUG
static void Command_Togglemodified_f(void);
#ifdef HAVE_BLUA
@@ -466,11 +469,14 @@ consvar_t cv_showping = {"showping", "Always", CV_SAVE, showping_cons_t, NULL, 0
static CV_PossibleValue_t pingmeasurement_cons_t[] = {{0, "Frames"}, {1, "Milliseconds"}, {0, NULL}};
consvar_t cv_pingmeasurement = {"pingmeasurement", "Frames", CV_SAVE, pingmeasurement_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
//consvar_t cv_smallpos = {"smallpositionnumber", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_showminimapnames = {"showminimapnames", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_minihead = {"smallminimapplayers", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_showlapemblem = {"showlapemblem", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_showviewpointtext = {"showviewpointtext", "On", CV_SAVE, CV_OnOff, 0, 0, NULL, NULL, 0, 0, NULL};
// Intermission time Tails 04-19-2002
@@ -705,6 +711,8 @@ void D_RegisterServerCommands(void)
CV_RegisterVar(&cv_powerstones);
CV_RegisterVar(&cv_competitionboxes);
CV_RegisterVar(&cv_matchboxes);
CV_RegisterVar(&cv_slamsound);
/*CV_RegisterVar(&cv_recycler);
CV_RegisterVar(&cv_teleporters);
@@ -771,10 +779,12 @@ void D_RegisterServerCommands(void)
CV_RegisterVar(&cv_showping);
CV_RegisterVar(&cv_pingmeasurement);
//CV_RegisterVar(&cv_smallpos);
CV_RegisterVar(&cv_showminimapnames);
CV_RegisterVar(&cv_minihead);
CV_RegisterVar(&cv_showlapemblem);
CV_RegisterVar(&cv_showtrackaddon);
@@ -964,6 +974,11 @@ void D_RegisterClientCommands(void)
CV_RegisterVar(&cv_mini_yoffset);
CV_RegisterVar(&cv_want_xoffset);
CV_RegisterVar(&cv_want_yoffset);
CV_RegisterVar(&cv_showinput);
CV_RegisterVar(&cv_newspeedometer);
CV_RegisterVar(&cv_saltyhop);
CV_RegisterVar(&cv_saltyhopsfx);
//CV_RegisterVar(&cv_crosshair);
//CV_RegisterVar(&cv_crosshair2);
@@ -1152,8 +1167,34 @@ void D_RegisterClientCommands(void)
CV_RegisterVar(&cv_discordstreamer);
CV_RegisterVar(&cv_discordasks);
#endif
COM_AddCommand("listskins", Command_ListSkins);
}
/**
* Searches the skins list for a skin of the "realname", if found, changes
* the CVAR value to be the "name" of the skin.
* \sa cv_skin, Skin_OnChange, Skin2_OnChange
* \author karen
*/
static void Skin_FindRealNameSkin(consvar_t *cvar)
{
// Not the best way to implements this but it will do.
int i;
const char *value = cvar->string;
for (i = 0; i < numskins; i++)
{
if (strncmp(value, skins[i].realname, sizeof skins[i].realname) == 0)
{
// Change the cvar to be the value of the name.
CV_StealthSet(cvar, skins[i].name);
return;
}
}
}
/** Checks if a name (as received from another player) is okay.
* A name is okay if it is no fewer than 1 and no more than ::MAXPLAYERNAME
* chars long (not including NUL), it does not begin or end with a space,
@@ -5746,6 +5787,8 @@ static void Name4_OnChange(void)
*/
static void Skin_OnChange(void)
{
Skin_FindRealNameSkin(&cv_skin);
if (!Playing())
return; // do whatever you want
@@ -5772,6 +5815,8 @@ static void Skin_OnChange(void)
*/
static void Skin2_OnChange(void)
{
Skin_FindRealNameSkin(&cv_skin2);
if (!Playing() || !splitscreen)
return; // do whatever you want
@@ -5786,6 +5831,8 @@ static void Skin2_OnChange(void)
static void Skin3_OnChange(void)
{
Skin_FindRealNameSkin(&cv_skin3);
if (!Playing() || splitscreen < 2)
return; // do whatever you want
@@ -5800,6 +5847,8 @@ static void Skin3_OnChange(void)
static void Skin4_OnChange(void)
{
Skin_FindRealNameSkin(&cv_skin4);
if (!Playing() || splitscreen < 3)
return; // do whatever you want
@@ -5812,6 +5861,74 @@ static void Skin4_OnChange(void)
}
}
static void Command_ListSkins(void)
{
int i;
int page = 0;
int numpages = numskins / 10 + (numskins % 10 ? 1 : 0);
int longest_name = 0;
if (COM_Argc() > 1)
{
if (sscanf(COM_Argv(1), " %d", &page) == 0)
{
CONS_Printf("Expected a number.\n");
return;
}
else if (page > numpages)
{
CONS_Printf("There are only %d pages.\n", numpages);
return;
}
else if (page < 0)
{
CONS_Printf("Page number cannot be negative.\n");
return;
}
else if (page == 0)
{
CONS_Printf("There is no 0th page. (What are you a programmer?)\n");
return;
}
--page;
}
CONS_Printf("Total %d skins. Page (%d/%d)\n", numskins, page + 1, numpages);
// Find the longest name and realname in the skins list. (used for alignment)
for (i = page * 10; i < numskins && i < (page + 1) * 10; i++)
{
int length;
skin_t *skin = &skins[i];
if ((length = strlen(skin->name)) > longest_name)
longest_name = length;
}
for (i = page * 10; i < numskins && i < (page + 1) * 10; i++)
{
skin_t *skin = &skins[i];
CONS_Printf(
"%s[%-*s]\x80 %s\n",
HU_SkinColorToConsoleColor(skin->prefcolor),
longest_name,
skin->name,
skin->realname);
}
if (page + 1 != numpages)
{
CONS_Printf("Use \"listskins %d\" to see the next page.\n", page + 2);
}
else
{
CONS_Printf("There are no more pages.\n");
}
}
/** Sends a color change for the console player, unless that player is moving.
* \sa cv_playercolor, Color2_OnChange, Skin_OnChange
* \author Graue <graue@oceanbase.org>
+2
View File
@@ -154,6 +154,8 @@ extern consvar_t cv_pingmeasurement;
extern consvar_t cv_showminimapnames;
extern consvar_t cv_minihead;
extern consvar_t cv_showlapemblem;
extern consvar_t cv_showviewpointtext;
extern consvar_t cv_skipmapcheck;
+1 -1
View File
@@ -562,7 +562,7 @@ INT32 CL_CheckFiles(void)
CONS_Debug(DBG_NETPLAY, "searching for '%s' ", fileneeded[i].filename);
// Check in already loaded files
for (j = mainwads+1; j < numwadfiles; j++)
for (j = mainwads+1; wadfiles[j]; j++)
{
nameonly(strcpy(wadfilename, wadfiles[j]->filename));
if (!stricmp(wadfilename, fileneeded[i].filename) &&
+63 -13
View File
@@ -545,8 +545,12 @@ static CV_PossibleValue_t stretchfactor_t[] = {{0, "MIN"}, {FRACUNIT, "MAX"}, {0
consvar_t cv_gravstretch = {"gravstretch", "0", CV_FLOAT | CV_SAVE, stretchfactor_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_sloperoll = {"sloperoll", "Off", CV_SAVE|CV_CALL, CV_OnOff, PDistort_menu_Onchange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_sliptideroll = {"sliptideroll", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
static CV_PossibleValue_t slamsound_t[] = {{0, "Off"}, {1, "On"}, {0, NULL}};
consvar_t cv_slamsound = {"slamsound", "1", CV_SAVE, slamsound_t, NULL, 0, NULL, NULL, 0, 0, NULL};
static CV_PossibleValue_t sloperolldist_cons_t[] = {
/*{256, "256"},*/ {512, "512"}, {768, "768"},
{1024, "1024"}, {1536, "1536"}, {2048, "2048"},
@@ -5699,6 +5703,9 @@ void G_GhostAddHit(INT32 playernum, mobj_t *victim)
void G_WriteAllGhostTics(void)
{
UINT8 *save_demo_p = demo_p;
#define CHECKSPACE(num) if (demo_p+(num) > demoend) { demo_p = save_demo_p; G_CheckDemoStatus(); return; }
INT32 i, counter = leveltime;
for (i = 0; i < MAXPLAYERS; i++)
{
@@ -5713,10 +5720,16 @@ void G_WriteAllGhostTics(void)
if (counter % cv_netdemosyncquality.value != 0) // Only write 1 in this many ghost datas per tic to cut down on multiplayer replay size.
continue;
CHECKSPACE(1);
WRITEUINT8(demo_p, i);
G_WriteGhostTic(players[i].mo, i);
}
CHECKSPACE(1);
WRITEUINT8(demo_p, 0xFF);
#undef CHECKSPACE
}
void G_WriteGhostTic(mobj_t *ghost, INT32 playernum)
@@ -5727,6 +5740,9 @@ void G_WriteGhostTic(mobj_t *ghost, INT32 playernum)
UINT8 sprite;
UINT8 frame;
UINT8 *save_demo_p = demo_p;
#define CHECKSPACE(num) if (demo_p+(num) > demoend) { demo_p = save_demo_p; G_CheckDemoStatus(); return; }
if (!demo_p)
return;
if (!(demoflags & DF_GHOST))
@@ -5753,6 +5769,8 @@ void G_WriteGhostTic(mobj_t *ghost, INT32 playernum)
oldghost[playernum].y = ghost->y;
oldghost[playernum].z = ghost->z;
ziptic |= GZT_XYZ;
CHECKSPACE(sizeof(fixed_t)*3);
WRITEFIXED(demo_p,oldghost[playernum].x);
WRITEFIXED(demo_p,oldghost[playernum].y);
WRITEFIXED(demo_p,oldghost[playernum].z);
@@ -5769,6 +5787,9 @@ void G_WriteGhostTic(mobj_t *ghost, INT32 playernum)
oldghost[playernum].momx = momx;
oldghost[playernum].momy = momy;
ziptic |= GZT_MOMXY;
CHECKSPACE(4);
WRITEINT16(demo_p,momx);
WRITEINT16(demo_p,momy);
}
@@ -5777,6 +5798,9 @@ void G_WriteGhostTic(mobj_t *ghost, INT32 playernum)
{
oldghost[playernum].momz = momx;
ziptic |= GZT_MOMZ;
CHECKSPACE(2);
WRITEINT16(demo_p,momx);
}
@@ -5797,6 +5821,9 @@ void G_WriteGhostTic(mobj_t *ghost, INT32 playernum)
{
oldghost[playernum].angle = ghost->angle>>24;
ziptic |= GZT_ANGLE;
CHECKSPACE(1);
WRITEUINT8(demo_p,oldghost[playernum].angle);
}
@@ -5806,6 +5833,9 @@ void G_WriteGhostTic(mobj_t *ghost, INT32 playernum)
{
oldghost[playernum].frame = frame;
ziptic |= GZT_SPRITE;
CHECKSPACE(1);
WRITEUINT8(demo_p,oldghost[playernum].frame);
}
@@ -5845,20 +5875,26 @@ void G_WriteGhostTic(mobj_t *ghost, INT32 playernum)
if (ghostext[playernum].flags & EZT_COLOR)
{
CHECKSPACE(1);
WRITEUINT8(demo_p,ghostext[playernum].color);
ghostext[playernum].lastcolor = ghostext[playernum].color;
}
if (ghostext[playernum].flags & EZT_SCALE)
{
CHECKSPACE(sizeof(fixed_t));
WRITEFIXED(demo_p,ghostext[playernum].scale);
ghostext[playernum].lastscale = ghostext[playernum].scale;
}
if (ghostext[playernum].flags & EZT_HIT)
{
CHECKSPACE(2);
WRITEUINT16(demo_p,ghostext[playernum].hits);
for (i = 0; i < ghostext[playernum].hits; i++)
{
mobj_t *mo = ghostext[playernum].hitlist[i];
CHECKSPACE(4+4+2+sizeof(fixed_t)*3+sizeof(angle_t));
WRITEUINT32(demo_p,UINT32_MAX); // reserved for some method of determining exactly which mobj this is. (mobjnum doesn't work here.)
WRITEUINT32(demo_p,mo->type);
WRITEUINT16(demo_p,(UINT16)mo->health);
@@ -5872,9 +5908,14 @@ void G_WriteGhostTic(mobj_t *ghost, INT32 playernum)
ghostext[playernum].hitlist = NULL;
}
if (ghostext[playernum].flags & EZT_SPRITE)
{
CHECKSPACE(1);
WRITEUINT8(demo_p,sprite);
}
if (ghostext[playernum].flags & EZT_KART)
{
CHECKSPACE(12);
WRITEINT32(demo_p, ghostext[playernum].kartitem);
WRITEINT32(demo_p, ghostext[playernum].kartamount);
WRITEINT32(demo_p, ghostext[playernum].kartbumpers);
@@ -5891,6 +5932,7 @@ void G_WriteGhostTic(mobj_t *ghost, INT32 playernum)
G_CheckDemoStatus(); // no more space
return;
}
#undef CHECKSPACE
}
void G_ConsAllGhostTics(void)
@@ -6743,22 +6785,30 @@ void G_RecordDemo(const char *name)
{
INT32 maxsize;
CONS_Printf("Recording demo %s.lmp\n", name);
strcpy(demoname, name);
strcat(demoname, ".lmp");
maxsize = cv_maxdemosize.value*1024*1024;
if (demobuffer)
free(demobuffer);
demo_p = NULL;
demo.recording = false;
demobuffer = malloc(maxsize);
demoend = demobuffer + maxsize;
if (demobuffer)
demo.recording = true;
else
CONS_Alert(CONS_ERROR, "Failed to allocate demo buffer\n");
free(demobuffer);
demobuffer = NULL;
demoend = NULL;
if (cv_recordmultiplayerdemos.value)
{
CONS_Printf("Recording demo %s.lmp\n", name);
strcpy(demoname, name);
strcat(demoname, ".lmp");
maxsize = cv_maxdemosize.value*1024*1024;
demobuffer = malloc(maxsize);
demoend = demobuffer + maxsize;
if (demobuffer)
demo.recording = true;
else
CONS_Alert(CONS_ERROR, "Failed to allocate demo buffer\n");
}
}
void G_RecordMetal(void)
+6
View File
@@ -145,11 +145,17 @@ extern consvar_t cv_mini_xoffset;
extern consvar_t cv_mini_yoffset;
extern consvar_t cv_want_xoffset;
extern consvar_t cv_want_yoffset;
extern consvar_t cv_showinput;
extern consvar_t cv_newspeedometer;
extern consvar_t cv_saltyhop;
extern consvar_t cv_saltyhopsfx;
extern consvar_t cv_driftsparkpulse;
extern consvar_t cv_gravstretch;
extern consvar_t cv_sloperoll;
extern consvar_t cv_sliptideroll;
extern consvar_t cv_slamsound;
extern consvar_t cv_sloperolldist;
extern consvar_t cv_invincmusicfade;
+3 -1
View File
@@ -46,7 +46,9 @@ EXPORT void HWRAPI(ClearMipMapCache) (void);
EXPORT void HWRAPI(SetSpecialState) (hwdspecialstate_t IdState, INT32 Value);
//Hurdler: added for new development
EXPORT void HWRAPI(DrawModel) (model_t *model, INT32 frameIndex, float duration, float tics, INT32 nextFrameIndex, FTransform *pos, float scale, UINT8 flipped, FSurfaceInfo *Surface);
EXPORT void HWRAPI(DrawModel) (model_t *model, INT32 frameIndex, float duration, float tics, INT32 nextFrameIndex, FTransform *pos, float hscale, float vscale, UINT8 flipped, FSurfaceInfo *Surface);
EXPORT void HWRAPI(CreateModelVBOs) (model_t *model);
EXPORT void HWRAPI(SetTransform) (FTransform *stransform);
EXPORT INT32 HWRAPI(GetTextureUsed) (void);
+25 -25
View File
@@ -194,7 +194,7 @@ FTransform atransform;
// Float variants of viewx, viewy, viewz, etc.
static float gr_viewx, gr_viewy, gr_viewz;
static float gr_viewsin, gr_viewcos;
float gr_viewsin, gr_viewcos;
static fixed_t dup_viewx, dup_viewy, dup_viewz;
@@ -3755,7 +3755,7 @@ static void HWR_DrawSpriteShadow(gr_vissprite_t *spr, GLPatch_t *gpatch, float t
}
// This is expecting a pointer to an array containing 4 wallVerts for a sprite
static void HWR_RotateSpritePolyToAim(gr_vissprite_t *spr, FOutVector *wallVerts)
static void HWR_RotateSpritePolyToAim(gr_vissprite_t *spr, FOutVector *wallVerts, const boolean precip)
{
if (cv_grspritebillboarding.value && spr && spr->mobj && !(spr->mobj->frame & FF_PAPERSPRITE) && wallVerts)
{
@@ -3907,7 +3907,7 @@ static void HWR_SplitSprite(gr_vissprite_t *spr)
}
// Let dispoffset work first since this adjust each vertex
HWR_RotateSpritePolyToAim(spr, baseWallVerts);
HWR_RotateSpritePolyToAim(spr, baseWallVerts, false);
// push it toward the camera to mitigate floor-clipping sprites
{
@@ -4254,7 +4254,7 @@ static void HWR_DrawSprite(gr_vissprite_t *spr)
// Let dispoffset work first since this adjust each vertex
// ...nah
HWR_RotateSpritePolyToAim(spr, wallVerts);
HWR_RotateSpritePolyToAim(spr, wallVerts, false);
// push it toward the camera to mitigate floor-clipping sprites
{
@@ -4348,7 +4348,7 @@ static inline void HWR_DrawPrecipitationSprite(gr_vissprite_t *spr)
wallVerts[1].z = wallVerts[2].z = spr->z2;
// Let dispoffset work first since this adjust each vertex
HWR_RotateSpritePolyToAim(spr, wallVerts);
HWR_RotateSpritePolyToAim(spr, wallVerts, true);
wallVerts[0].s = wallVerts[3].s = 0;
wallVerts[2].s = wallVerts[1].s = gpatch->max_s;
@@ -5074,6 +5074,7 @@ void HWR_ProjectSprite(mobj_t *thing)
spr_offset = rotsprite->leftoffset << FRACBITS;
spr_topoffset = rotsprite->topoffset << FRACBITS;
spr_topoffset += FEETADJUST;
// flip -> rotate, not rotate -> flip
flip = 0;
}
@@ -5129,13 +5130,13 @@ void HWR_ProjectSprite(mobj_t *thing)
if (thing->eflags & MFE_VERTICALFLIP)
{
gz = FIXED_TO_FLOAT(interp.z+thing->height) - FIXED_TO_FLOAT(spr_topoffset) * this_yscale;
gzt = gz + FIXED_TO_FLOAT(spr_height) * this_yscale;
gz = FIXED_TO_FLOAT(interp.z + thing->height) - (FIXED_TO_FLOAT(spr_topoffset) * this_yscale);
gzt = gz + (FIXED_TO_FLOAT(spr_height) * this_yscale);
}
else
{
gzt = FIXED_TO_FLOAT(interp.z) + FIXED_TO_FLOAT(spr_topoffset) * this_yscale;
gz = gzt - FIXED_TO_FLOAT(spr_height) * this_yscale;
gzt = FIXED_TO_FLOAT(interp.z) + (FIXED_TO_FLOAT(spr_topoffset) * this_yscale);
gz = gzt - (FIXED_TO_FLOAT(spr_height) * this_yscale);
}
if (thing->subsector->sector->cullheight)
@@ -5177,10 +5178,10 @@ void HWR_ProjectSprite(mobj_t *thing)
vis->spriteyscale = spriteyscale;
vis->spritexoffset = FIXED_TO_FLOAT(spr_offset);
vis->spriteyoffset = FIXED_TO_FLOAT(spr_topoffset);
//vis->patchlumpnum = sprframe->lumppat[rot];
#ifdef ROTSPRITE
if (rotsprite)
vis->gpatch = (GLPatch_t *)rotsprite;
vis->gpatch = (GLPatch_t *)rotsprite;
else
#endif
vis->gpatch = (GLPatch_t *)W_CachePatchNum(sprframe->lumppat[rot], PU_CACHE);
@@ -5252,11 +5253,11 @@ void HWR_ProjectPrecipitationSprite(precipmobj_t *thing)
unsigned rot = 0;
UINT8 flip;
// uncapped/interpolation
interpmobjstate_t interp = {0};
if (!thing)
return;
// uncapped/interpolation
interpmobjstate_t interp = {0};
// do interpolation
if (R_UsingFrameInterpolation() && !paused)
@@ -5325,16 +5326,6 @@ void HWR_ProjectPrecipitationSprite(precipmobj_t *thing)
x1 = tr_x + x1 * rightcos;
x2 = tr_x - x2 * rightcos;
// okay, we can't return now... this is a hack, but weather isn't networked, so it should be ok
if (!(thing->precipflags & PCF_THUNK))
{
if (thing->precipflags & PCF_RAIN)
P_RainThinker(thing);
else
P_SnowThinker(thing);
thing->precipflags |= PCF_THUNK;
}
//
// store information in a vissprite
//
@@ -5345,7 +5336,6 @@ void HWR_ProjectPrecipitationSprite(precipmobj_t *thing)
vis->z2 = z2;
vis->tz = tz;
vis->dispoffset = 0; // Monster Iestyn: 23/11/15: HARDWARE SUPPORT AT LAST
//vis->patchlumpnum = sprframe->lumppat[rot];
vis->gpatch = (GLPatch_t *)W_CachePatchNum(sprframe->lumppat[rot], PU_CACHE);
vis->flip = flip;
vis->mobj = (mobj_t *)thing;
@@ -5364,6 +5354,16 @@ void HWR_ProjectPrecipitationSprite(precipmobj_t *thing)
vis->gz = vis->gzt - FIXED_TO_FLOAT(spritecachedinfo[lumpoff].height);
vis->precip = true;
// okay... this is a hack, but weather isn't networked, so it should be ok
if (!(thing->precipflags & PCF_THUNK))
{
if (thing->precipflags & PCF_RAIN)
P_RainThinker(thing);
else
P_SnowThinker(thing);
thing->precipflags |= PCF_THUNK;
}
}
static boolean drewsky = false;
+1
View File
@@ -45,6 +45,7 @@ extern unsigned msaa;
extern boolean a2c;
extern FTransform atransform;
extern float gr_viewsin, gr_viewcos;
// Performance stats
extern ps_metric_t ps_hw_nodesorttime;
+16 -8
View File
@@ -1144,7 +1144,6 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
spriteinfo_t *sprinfo;
INT32 rollfactor = 0;
angle_t ang;
float finalscale;
interpmobjstate_t interp;
if (R_UsingFrameInterpolation() && !paused)
@@ -1204,7 +1203,6 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
return;
}
}
finalscale = md2->scale;
//Hurdler: arf, I don't like that implementation at all... too much crappy
gpatch = md2->grpatch;
if (!gpatch || ((!gpatch->mipmap->grInfo.format || !gpatch->mipmap->downloaded) && !gpatch->notfound))
@@ -1386,18 +1384,28 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
}
#endif
// SRB2CBTODO: MD2 scaling support
finalscale *= FIXED_TO_FLOAT(interp.scale);
p.flip = atransform.flip;
#ifdef USE_FTRANSFORM_MIRROR
p.mirror = atransform.mirror; // from Kart
#endif
HWD.pfnSetShader(4); // model shader
HWD.pfnDrawModel(md2->model, frame, durs, tics, nextFrame, &p, finalscale, flip, &Surf);
{
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);
float ox = xs * FIXED_TO_FLOAT(interp.spritexoffset);
float oy = ys * FIXED_TO_FLOAT(interp.spriteyoffset);
// offset perpendicular to the camera angle
p.x -= ox * gr_viewsin;
p.y += ox * gr_viewcos;
p.z += oy;
HWD.pfnDrawModel(md2->model, frame, durs, tics, nextFrame, &p, md2->scale * xs, md2->scale * ys, flip, &Surf);
}
}
}
+8 -49
View File
@@ -3040,67 +3040,26 @@ EXPORT void HWRAPI(CreateModelVBOs) (model_t *model)
#define BUFFER_OFFSET(i) ((char*)(i))
static void DrawModelEx(model_t *model, INT32 frameIndex, float duration, float tics, INT32 nextFrameIndex, FTransform *pos, float scale, UINT8 flipped, FSurfaceInfo *Surface)
static void DrawModelEx(model_t *model, INT32 frameIndex, float duration, float tics, INT32 nextFrameIndex, FTransform *pos, float hscale, float vscale, UINT8 flipped, FSurfaceInfo *Surface)
{
static GLRGBAFloat poly = {0,0,0,0};
static GLRGBAFloat tint = {0,0,0,0};
static GLRGBAFloat fade = {0,0,0,0};
const float radians = (float)(M_PIl / 180.0f);
float pol = 0.0f;
float scalex, scaley, scalez;
float sprxscale, spryscale;
float scalediffx, scalediffy;
int dfx, dfy;
float rollradian;
float scalecosx, scalesinx, scalecosy, scalesiny;
boolean useTinyFrames;
int i;
sprxscale = pos->spritexscale;
spryscale = pos->spriteyscale;
rollradian = 0;
rollradian = (pos->rollangle)*radians;
// Affect input model scaling
hscale *= 0.5f;
vscale *= 0.5f;
scalex = hscale;
scaley = vscale;
scalez = hscale;
// this is hilariously insane but it's late as fuck and I can't be inclined to care
scalediffx = (sprxscale*scale) - scale;
scalediffy = (spryscale*scale) - scale;
scale *= 0.5f;
sprxscale *= 1.5f;
spryscale *= 1.5f;
scalediffx *= 0.5f;
scalediffy *= 0.5f;
dfx = 1;
dfy = 1;
if (scalediffx < 0)
dfx = -1;
if (scalediffy < 0)
dfy = -1;
scalecosx = (fabs(scalediffx*cos(rollradian))*dfx);
scalesinx = (fabs(scalediffx*sin(rollradian))*dfx);
scalecosy = (fabs(scalediffy*sin(rollradian))*dfy);
scalesiny = (fabs(scalediffy*cos(rollradian))*dfy);
// "sprite accurate" model scaling, so that stretchy things don't look all that funky from any angle not the default
scalex = scale+scalecosx+scalecosy;
scaley = scale+scalesinx+scalesiny;
scalez = scale+scalecosx+scalecosy;
if (duration > 0.0 && tics >= 0.0) // don't interpolate if instantaneous or infinite in length
{
float newtime = (duration - tics); // + 1;
@@ -3293,9 +3252,9 @@ static void DrawModelEx(model_t *model, INT32 frameIndex, float duration, float
// -----------------+
// HWRAPI DrawModel : Draw a model
// -----------------+
EXPORT void HWRAPI(DrawModel) (model_t *model, INT32 frameIndex, float duration, float tics, INT32 nextFrameIndex, FTransform *pos, float scale, UINT8 flipped, FSurfaceInfo *Surface)
EXPORT void HWRAPI(DrawModel) (model_t *model, INT32 frameIndex, float duration, float tics, INT32 nextFrameIndex, FTransform *pos, float hscale, float vscale, UINT8 flipped, FSurfaceInfo *Surface)
{
DrawModelEx(model, frameIndex, duration, tics, nextFrameIndex, pos, scale, flipped, Surface);
DrawModelEx(model, frameIndex, duration, tics, nextFrameIndex, pos, hscale, vscale, flipped, Surface);
}
// -----------------+
+133 -139
View File
@@ -81,6 +81,8 @@ patch_t *pingnum[10];
patch_t *pinggfx[5]; // small ping graphic
patch_t *pingmeasure[2]; // ping measurement graphic
patch_t *ranknum[10]; // rank numbers
patch_t *framecounter;
patch_t *frameslash; // framerate stuff. Used in screen.c
@@ -281,6 +283,8 @@ void HU_LoadGraphics(void)
nightsnum[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX);
sprintf(buffer, "PINGN%d", i);
pingnum[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX);
sprintf(buffer, "OPPRNK0%d", i);
ranknum[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX);
}
// minus for negative tallnums
@@ -682,6 +686,134 @@ static void Command_CSay_f(void)
}
static tic_t stop_spamming[MAXPLAYERS];
const char *HU_SkinColorToConsoleColor(skincolors_t color)
{
// Move this ugly switch into a function you can collapse.
switch (color)
{
case SKINCOLOR_WHITE:
case SKINCOLOR_SILVER:
case SKINCOLOR_SLATE:
return "\x80"; // White
case SKINCOLOR_GREY:
case SKINCOLOR_NICKEL:
case SKINCOLOR_BLACK:
case SKINCOLOR_SKUNK:
case SKINCOLOR_JET:
return "\x86"; // V_GRAYMAP
case SKINCOLOR_SEPIA:
case SKINCOLOR_BEIGE:
case SKINCOLOR_WALNUT:
case SKINCOLOR_BROWN:
case SKINCOLOR_LEATHER:
case SKINCOLOR_RUST:
case SKINCOLOR_WRISTWATCH:
return "\x8e"; // V_BROWNMAP
case SKINCOLOR_FAIRY:
case SKINCOLOR_SALMON:
case SKINCOLOR_PINK:
case SKINCOLOR_ROSE:
case SKINCOLOR_BRICK:
case SKINCOLOR_LEMONADE:
case SKINCOLOR_BUBBLEGUM:
case SKINCOLOR_LILAC:
return "\x8d"; // V_PINKMAP
case SKINCOLOR_CINNAMON:
case SKINCOLOR_RUBY:
case SKINCOLOR_RASPBERRY:
case SKINCOLOR_CHERRY:
case SKINCOLOR_RED:
case SKINCOLOR_CRIMSON:
case SKINCOLOR_MAROON:
case SKINCOLOR_FLAME:
case SKINCOLOR_SCARLET:
case SKINCOLOR_KETCHUP:
return "\x85"; // V_REDMAP
case SKINCOLOR_DAWN:
case SKINCOLOR_SUNSET:
case SKINCOLOR_CREAMSICLE:
case SKINCOLOR_ORANGE:
case SKINCOLOR_PUMPKIN:
case SKINCOLOR_ROSEWOOD:
case SKINCOLOR_BURGUNDY:
case SKINCOLOR_TANGERINE:
return "\x87"; // V_ORANGEMAP
case SKINCOLOR_PEACH:
case SKINCOLOR_CARAMEL:
case SKINCOLOR_CREAM:
return "\x8f"; // V_PEACHMAP
case SKINCOLOR_GOLD:
case SKINCOLOR_ROYAL:
case SKINCOLOR_BRONZE:
case SKINCOLOR_COPPER:
case SKINCOLOR_THUNDER:
return "\x8A"; // V_GOLDMAP
case SKINCOLOR_POPCORN:
case SKINCOLOR_QUARRY:
case SKINCOLOR_YELLOW:
case SKINCOLOR_MUSTARD:
case SKINCOLOR_CROCODILE:
case SKINCOLOR_OLIVE:
return "\x82"; // V_YELLOWMAP
case SKINCOLOR_ARTICHOKE:
case SKINCOLOR_VOMIT:
case SKINCOLOR_GARDEN:
case SKINCOLOR_TEA:
case SKINCOLOR_PISTACHIO:
return "\x8b"; // V_TEAMAP
case SKINCOLOR_LIME:
case SKINCOLOR_HANDHELD:
case SKINCOLOR_MOSS:
case SKINCOLOR_CAMOUFLAGE:
case SKINCOLOR_ROBOHOOD:
case SKINCOLOR_MINT:
case SKINCOLOR_GREEN:
case SKINCOLOR_PINETREE:
case SKINCOLOR_EMERALD:
case SKINCOLOR_SWAMP:
case SKINCOLOR_DREAM:
case SKINCOLOR_PLAGUE:
case SKINCOLOR_ALGAE:
return "\x83"; // V_GREENMAP
case SKINCOLOR_CARIBBEAN:
case SKINCOLOR_AZURE:
case SKINCOLOR_AQUA:
case SKINCOLOR_TEAL:
case SKINCOLOR_CYAN:
case SKINCOLOR_JAWZ:
case SKINCOLOR_CERULEAN:
case SKINCOLOR_NAVY:
case SKINCOLOR_SAPPHIRE:
return "\x88"; // V_SKYMAP
case SKINCOLOR_PIGEON:
case SKINCOLOR_PLATINUM:
case SKINCOLOR_STEEL:
return "\x8c"; // V_STEELMAP
case SKINCOLOR_PERIWINKLE:
case SKINCOLOR_BLUE:
case SKINCOLOR_BLUEBERRY:
case SKINCOLOR_NOVA:
return "\x84"; // V_BLUEMAP
case SKINCOLOR_ULTRAVIOLET:
case SKINCOLOR_PURPLE:
case SKINCOLOR_FUCHSIA:
return "\x81"; // V_PURPLEMAP
case SKINCOLOR_PASTEL:
case SKINCOLOR_MOONSLAM:
case SKINCOLOR_DUSK:
case SKINCOLOR_TOXIC:
case SKINCOLOR_MAUVE:
case SKINCOLOR_LAVENDER:
case SKINCOLOR_BYZANTIUM:
case SKINCOLOR_POMEGRANATE:
return "\x89"; // V_LAVENDERMAP
default:
return "\x83";
}
}
/** Receives a message, processing an ::XD_SAY command.
* \sa DoSayCommand
* \author Graue <graue@oceanbase.org>
@@ -828,145 +960,7 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum)
{
const UINT8 color = players[playernum].skincolor;
cstart = "\x83";
switch (color)
{
case SKINCOLOR_WHITE:
case SKINCOLOR_SILVER:
case SKINCOLOR_SLATE:
cstart = "\x80"; // White
break;
case SKINCOLOR_GREY:
case SKINCOLOR_NICKEL:
case SKINCOLOR_BLACK:
case SKINCOLOR_SKUNK:
case SKINCOLOR_JET:
cstart = "\x86"; // V_GRAYMAP
break;
case SKINCOLOR_SEPIA:
case SKINCOLOR_BEIGE:
case SKINCOLOR_WALNUT:
case SKINCOLOR_BROWN:
case SKINCOLOR_LEATHER:
case SKINCOLOR_RUST:
case SKINCOLOR_WRISTWATCH:
cstart = "\x8e"; // V_BROWNMAP
break;
case SKINCOLOR_FAIRY:
case SKINCOLOR_SALMON:
case SKINCOLOR_PINK:
case SKINCOLOR_ROSE:
case SKINCOLOR_BRICK:
case SKINCOLOR_LEMONADE:
case SKINCOLOR_BUBBLEGUM:
case SKINCOLOR_LILAC:
cstart = "\x8d"; // V_PINKMAP
break;
case SKINCOLOR_CINNAMON:
case SKINCOLOR_RUBY:
case SKINCOLOR_RASPBERRY:
case SKINCOLOR_CHERRY:
case SKINCOLOR_RED:
case SKINCOLOR_CRIMSON:
case SKINCOLOR_MAROON:
case SKINCOLOR_FLAME:
case SKINCOLOR_SCARLET:
case SKINCOLOR_KETCHUP:
cstart = "\x85"; // V_REDMAP
break;
case SKINCOLOR_DAWN:
case SKINCOLOR_SUNSET:
case SKINCOLOR_CREAMSICLE:
case SKINCOLOR_ORANGE:
case SKINCOLOR_PUMPKIN:
case SKINCOLOR_ROSEWOOD:
case SKINCOLOR_BURGUNDY:
case SKINCOLOR_TANGERINE:
cstart = "\x87"; // V_ORANGEMAP
break;
case SKINCOLOR_PEACH:
case SKINCOLOR_CARAMEL:
case SKINCOLOR_CREAM:
cstart = "\x8f"; // V_PEACHMAP
break;
case SKINCOLOR_GOLD:
case SKINCOLOR_ROYAL:
case SKINCOLOR_BRONZE:
case SKINCOLOR_COPPER:
case SKINCOLOR_THUNDER:
cstart = "\x8A"; // V_GOLDMAP
break;
case SKINCOLOR_POPCORN:
case SKINCOLOR_QUARRY:
case SKINCOLOR_YELLOW:
case SKINCOLOR_MUSTARD:
case SKINCOLOR_CROCODILE:
case SKINCOLOR_OLIVE:
cstart = "\x82"; // V_YELLOWMAP
break;
case SKINCOLOR_ARTICHOKE:
case SKINCOLOR_VOMIT:
case SKINCOLOR_GARDEN:
case SKINCOLOR_TEA:
case SKINCOLOR_PISTACHIO:
cstart = "\x8b"; // V_TEAMAP
break;
case SKINCOLOR_LIME:
case SKINCOLOR_HANDHELD:
case SKINCOLOR_MOSS:
case SKINCOLOR_CAMOUFLAGE:
case SKINCOLOR_ROBOHOOD:
case SKINCOLOR_MINT:
case SKINCOLOR_GREEN:
case SKINCOLOR_PINETREE:
case SKINCOLOR_EMERALD:
case SKINCOLOR_SWAMP:
case SKINCOLOR_DREAM:
case SKINCOLOR_PLAGUE:
case SKINCOLOR_ALGAE:
cstart = "\x83"; // V_GREENMAP
break;
case SKINCOLOR_CARIBBEAN:
case SKINCOLOR_AZURE:
case SKINCOLOR_AQUA:
case SKINCOLOR_TEAL:
case SKINCOLOR_CYAN:
case SKINCOLOR_JAWZ:
case SKINCOLOR_CERULEAN:
case SKINCOLOR_NAVY:
case SKINCOLOR_SAPPHIRE:
cstart = "\x88"; // V_SKYMAP
break;
case SKINCOLOR_PIGEON:
case SKINCOLOR_PLATINUM:
case SKINCOLOR_STEEL:
cstart = "\x8c"; // V_STEELMAP
break;
case SKINCOLOR_PERIWINKLE:
case SKINCOLOR_BLUE:
case SKINCOLOR_BLUEBERRY:
case SKINCOLOR_NOVA:
cstart = "\x84"; // V_BLUEMAP
break;
case SKINCOLOR_ULTRAVIOLET:
case SKINCOLOR_PURPLE:
case SKINCOLOR_FUCHSIA:
cstart = "\x81"; // V_PURPLEMAP
break;
case SKINCOLOR_PASTEL:
case SKINCOLOR_MOONSLAM:
case SKINCOLOR_DUSK:
case SKINCOLOR_TOXIC:
case SKINCOLOR_MAUVE:
case SKINCOLOR_LAVENDER:
case SKINCOLOR_BYZANTIUM:
case SKINCOLOR_POMEGRANATE:
cstart = "\x89"; // V_LAVENDERMAP
break;
default:
break;
}
cstart = HU_SkinColorToConsoleColor(color);
}
prefix = cstart;
+2
View File
@@ -83,6 +83,7 @@ extern patch_t *hu_font[HU_FONTSIZE], *kart_font[KART_FONTSIZE], *tny_font[HU_FO
extern patch_t *tallnum[10];
extern patch_t *pingnum[10];
extern patch_t *pinggfx[5];
extern patch_t *ranknum[10];
extern patch_t *nightsnum[10];
extern patch_t *framecounter;
extern patch_t *frameslash;
@@ -121,6 +122,7 @@ void HU_drawPing(INT32 x, INT32 y, UINT32 ping, INT32 flags); // Lat': Ping draw
//void HU_DrawDualTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, INT32 whiteplayer);
void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, INT32 whiteplayer, INT32 hilicol);
void HU_DrawEmeralds(INT32 x, INT32 y, INT32 pemeralds);
const char *HU_SkinColorToConsoleColor(skincolors_t color);
INT32 HU_CreateTeamScoresTbl(playersort_t *tab, UINT32 dmtotals[]);
+162 -24
View File
@@ -22,6 +22,7 @@
#include "f_finale.h"
#include "lua_hud.h" // For Lua hud checks
#include "lua_hook.h" // For MobjDamage and ShouldDamage
#include "d_main.h" // found_extra_kart
// Hud offset cvars
consvar_t cv_item_xoffset = {"hud_item_xoffset", "0", CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL};
@@ -53,6 +54,12 @@ consvar_t cv_mini_yoffset = {"hud_minimap_yoffset", "0", CV_SAVE, NULL, NULL, 0,
consvar_t cv_want_xoffset = {"hud_wanted_xoffset", "0", CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_want_yoffset = {"hud_wanted_yoffset", "0", CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_showinput = {"showinput", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_newspeedometer = {"newspeedometer", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_saltyhop = {"hardcodehop", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_saltyhopsfx = {"hardcodehopsfx", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
// SOME IMPORTANT VARIABLES DEFINED IN DOOMDEF.H:
// gamespeed is cc (0 for easy, 1 for normal, 2 for hard)
// franticitems is Frantic Mode items, bool
@@ -3001,6 +3008,15 @@ static void K_StretchPlayerGravity(player_t *p)
I_Assert(p->mo != NULL);
I_Assert(!P_MobjWasRemoved(p->mo));
if (p->mo->slamsoundtimer)
p->mo->slamsoundtimer--;
if (cv_slamsound.value == 1 && (p->mo->eflags & MFE_JUSTHITFLOOR) && p->mo->stretchslam > 4*mos && !p->mo->slamsoundtimer)
{
S_StartSound(p->mo, sfx_s3k4c);
p->mo->slamsoundtimer = TICRATE;
}
if (!P_IsObjectOnGround(p->mo))
{
if (zspd != 0)
@@ -3033,10 +3049,70 @@ static void K_StretchPlayerGravity(player_t *p)
p->mo->stretchslam -= (4*mos);
else
p->mo->stretchslam = 0;
}
}
static void K_QuiteSaltyHop(player_t *p)
{
// what the fuck is this haya
fixed_t mos = FRACUNIT; // doesnt work correctly if it isnt :/
// ready?
if (!p->kartstuff[k_jmp]) {
p->mo->salty_ready = true;
p->mo->salty_tapping = false;
} else if (p->mo->salty_ready) {
p->mo->salty_ready = false;
p->mo->salty_tapping = true;
} else {
p->mo->salty_tapping = false;
}
// GO!
if (!p->mo->init_salty) {
p->mo->salty_jump = false;
p->mo->salty_zoffset = 0;
p->mo->salty_momz = 0;
p->mo->init_salty = true;
}
else if (p->mo->salty_jump) {
if (p->mo->eflags & MFE_JUSTHITFLOOR) {
p->mo->salty_zoffset = 0;
} else if (P_IsObjectOnGround(p->mo)) {
p->mo->salty_zoffset += p->mo->salty_momz;
p->mo->salty_momz -= (mos*3/2);
} else {
p->mo->salty_zoffset *= (49/50)*mos;
p->mo->salty_momz = 0;
}
if (p->mo->salty_zoffset <= 0) {
if (!(p->mo->eflags & MFE_JUSTHITFLOOR) && P_IsObjectOnGround(p->mo) && cv_saltyhopsfx.value)
S_StartSound(p->mo, sfx_s268);
p->mo->salty_jump = false;
p->mo->salty_zoffset = 0;
p->mo->salty_momz = 0;
// shlamma damma
p->mo->stretchslam += (8*mos);
} else if (p->mo->salty_zoffset >= 0) {
// goofy ahh hack
p->mo->spriteyscale += (mos/8);
p->mo->spritexscale -= (mos/8);
}
p->mo->spriteyoffset = p->mo->salty_zoffset*P_MobjFlip(p->mo);
if (S_SoundPlaying(p->mo, sfx_screec))
S_StopSoundByID(p->mo, sfx_screec);
if (S_SoundPlaying(p->mo, sfx_drift))
S_StopSoundByID(p->mo, sfx_drift);
}
else if (p->mo->salty_tapping && P_IsObjectOnGround(p->mo) && !p->kartstuff[k_spinouttimer] && !p->kartstuff[k_squishedtimer]) {
p->mo->salty_jump = true;
p->mo->salty_zoffset = 0;
p->mo->salty_momz = 6*mos;
if (cv_saltyhopsfx.value)
S_StartSound(p->mo, sfx_s25a);
}
}
static INT32 K_FindPlayerNum(player_t *plyr)
{
INT32 i;
@@ -6392,6 +6468,16 @@ void K_MoveKartPlayer(player_t *player, boolean onground)
player->kartstuff[k_boostcharge] = 0;
}
// salty hop! i wanna die
if (cv_saltyhop.value)
K_QuiteSaltyHop(player);
else {
player->mo->spriteyoffset = 0;
player->mo->salty_jump = false;
player->mo->salty_zoffset = 0;
player->mo->salty_momz = 0;
}
}
void K_CalculateBattleWanted(void)
@@ -6817,6 +6903,9 @@ static patch_t *kp_lapanim_hand[3];
static patch_t *kp_yougotem;
static patch_t *skp_smallsticker;
static patch_t *skp_speedpatches[5];
void K_LoadKartHUDGraphics(void)
{
INT32 i, j;
@@ -7063,6 +7152,16 @@ void K_LoadKartHUDGraphics(void)
}
kp_yougotem = (patch_t *) W_CachePatchName("YOUGOTEM", PU_HUDGFX);
if (found_extra_kart) // snowy speedometer
{
skp_smallsticker = W_CachePatchName("SP_SMSTC", PU_HUDGFX);
skp_speedpatches[0] = W_CachePatchName("K_TRNULL", PU_HUDGFX); // lolxd
skp_speedpatches[1] = W_CachePatchName("SP_MKMH", PU_HUDGFX);
skp_speedpatches[2] = W_CachePatchName("SP_MMPH", PU_HUDGFX);
skp_speedpatches[3] = W_CachePatchName("SP_MFRAC", PU_HUDGFX);
skp_speedpatches[4] = W_CachePatchName("SP_MPERC", PU_HUDGFX);
}
}
// For the item toggle menu
@@ -8205,35 +8304,62 @@ static void K_drawKartLaps(void)
static void K_drawKartSpeedometer(void)
{
fixed_t convSpeed;
// why?
if (cv_kartspeedometer.value == 0)
return;
fixed_t convSpeed = 0;
INT32 speedtype = 0;
INT32 splitflags = K_calcSplitFlags(V_SNAPTOBOTTOM|V_SNAPTOLEFT);
if (cv_kartspeedometer.value == 1) // Kilometers
switch (cv_kartspeedometer.value)
{
convSpeed = FixedDiv(FixedMul(stplyr->speed, 142371), mapobjectscale)/FRACUNIT; // 2.172409058
V_DrawKartString(SPDM_X, SPDM_Y, V_HUDTRANS|splitflags, va("%3d km/h", convSpeed));
case 1:
convSpeed = FixedDiv(FixedMul(stplyr->speed, 142371), mapobjectscale)/FRACUNIT; // 2.172409058
speedtype = 1;
break;
case 2:
convSpeed = FixedDiv(FixedMul(stplyr->speed, 142371), mapobjectscale)/FRACUNIT; // 2.172409058
speedtype = 2;
break;
case 3:
convSpeed = FixedDiv(FixedMul(stplyr->speed, 88465), mapobjectscale)/FRACUNIT; // 1.349868774
speedtype = 3;
break;
case 4:
if (stplyr->mo)
convSpeed = (FixedDiv(stplyr->speed, FixedMul(K_GetKartSpeed(stplyr, false), ORIG_FRICTION))*100)>>FRACBITS;
speedtype = 4;
break;
default:
break;
}
else if (cv_kartspeedometer.value == 2) // Miles
// man.
if ((!cv_newspeedometer.value) || (cv_newspeedometer.value && !found_extra_kart))
{
convSpeed = FixedDiv(FixedMul(stplyr->speed, 88465), mapobjectscale)/FRACUNIT; // 1.349868774
V_DrawKartString(SPDM_X, SPDM_Y, V_HUDTRANS|splitflags, va("%3d mph", convSpeed));
}
else if (cv_kartspeedometer.value == 3) // Fracunits
{
convSpeed = FixedDiv(stplyr->speed, mapobjectscale)/FRACUNIT;
V_DrawKartString(SPDM_X, SPDM_Y, V_HUDTRANS|splitflags, va("%3d fu/t", convSpeed));
}
else if (cv_kartspeedometer.value == 4) // Percent
{
// so code breaks if someone attempts to join from spectator since it sets
// their mo to NULL
// so can we just check if their mo is NULL????
if (stplyr->mo)
{
convSpeed = (FixedDiv(stplyr->speed, FixedMul(K_GetKartSpeed(stplyr, false), ORIG_FRICTION))*100)>>FRACBITS;
V_DrawKartString(SPDM_X, SPDM_Y, V_HUDTRANS|splitflags, va("%4d P", convSpeed));
switch (speedtype) {
case 1:
V_DrawKartString(SPDM_X, SPDM_Y, V_HUDTRANS|splitflags, va("%03d km/h", convSpeed));
break;
case 2:
V_DrawKartString(SPDM_X, SPDM_Y, V_HUDTRANS|splitflags, va("%03d mph", convSpeed));
break;
case 3:
V_DrawKartString(SPDM_X, SPDM_Y, V_HUDTRANS|splitflags, va("%03d fu/t", convSpeed));
break;
case 4: // if extra.kart is found, use its included % symbol
if (!found_extra_kart)
V_DrawKartString(SPDM_X, SPDM_Y, V_HUDTRANS|splitflags, va("%03d P", convSpeed));
else
V_DrawKartString(SPDM_X, SPDM_Y, V_HUDTRANS|splitflags, va("%03d %%", convSpeed));
}
}
else if (cv_newspeedometer.value && found_extra_kart) { // why bother if we dont?
V_DrawScaledPatch(SPDM_X + 1, SPDM_Y + 4, V_HUDTRANS|splitflags, skp_smallsticker);
V_DrawRankNum(SPDM_X + 26, SPDM_Y + 4, V_HUDTRANS|splitflags, convSpeed, 3, NULL);
V_DrawScaledPatch(SPDM_X + 31, SPDM_Y + 4, V_HUDTRANS|splitflags, skp_speedpatches[cv_kartspeedometer.value]);
}
}
static void K_drawKartBumpersOrKarma(void)
@@ -9009,9 +9135,12 @@ static void K_drawKartFirstPerson(void)
// doesn't need to ever support 4p
static void K_drawInput(void)
{
if (!cv_showinput.value && !modeattacking) // dont bother
return;
static INT32 pn = 0;
INT32 target = 0, splitflags = (V_SNAPTOBOTTOM|V_SNAPTORIGHT);
INT32 x = BASEVIDWIDTH - 32, y = BASEVIDHEIGHT-24, offs, col;
INT32 x = BASEVIDWIDTH - 32 + cv_posi_xoffset.value, y = BASEVIDHEIGHT-24 + cv_posi_yoffset.value, offs, col;
const INT32 accent1 = splitflags|colortranslations[stplyr->skincolor][5];
const INT32 accent2 = splitflags|colortranslations[stplyr->skincolor][9];
ticcmd_t *cmd = &stplyr->cmd;
@@ -9117,6 +9246,9 @@ static void K_drawChallengerScreen(void)
static void K_drawLapStartAnim(void)
{
if (! cv_showlapemblem.value)
return;
// This is an EVEN MORE insanely complicated animation.
const UINT8 progress = 80-stplyr->kartstuff[k_lapanimation];
UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, stplyr->skincolor, GTC_CACHE);
@@ -9393,6 +9525,12 @@ void K_drawKartHUD(void)
if (!stplyr->spectator && !demo.freecam) // Bottom of the screen elements, don't need in spectate mode
{
if (!(splitscreen || demo.title))
#ifdef HAVE_BLUA
if (LUA_HudEnabled(hud_position))
#endif
K_drawInput();
if (demo.title) // Draw title logo instead in demo.titles
{
INT32 x = BASEVIDWIDTH - 32, y = 128, offs;
+3 -3
View File
@@ -84,7 +84,7 @@ huddrawlist_h LUA_HUD_CreateDrawList(void)
{
huddrawlist_h drawlist;
drawlist = (huddrawlist_h) Z_Calloc(sizeof(struct huddrawlist_s), PU_STATIC, NULL);
drawlist = (huddrawlist_h) Z_CallocAlign(sizeof(struct huddrawlist_s), PU_STATIC, NULL, 64);
drawlist->items = NULL;
drawlist->items_capacity = 0;
drawlist->items_len = 0;
@@ -145,7 +145,7 @@ static size_t AllocateDrawItem(huddrawlist_h list)
{
if (list->items_capacity == 0) list->items_capacity = 128;
else list->items_capacity *= 2;
list->items = (drawitem_t *) Z_Realloc(list->items, sizeof(struct drawitem_s) * list->items_capacity, PU_STATIC, NULL);
list->items = (drawitem_t *) Z_ReallocAlign(list->items, sizeof(struct drawitem_s) * list->items_capacity, PU_STATIC, NULL, 64);
}
return list->items_len++;
@@ -164,7 +164,7 @@ static size_t CopyString(huddrawlist_h list, const char* str)
{
if (list->strbuf_capacity == 0) list->strbuf_capacity = 256;
else list->strbuf_capacity *= 2;
list->strbuf = (char*) Z_Realloc(list->strbuf, sizeof(char) * list->strbuf_capacity, PU_STATIC, NULL);
list->strbuf = (char*) Z_ReallocAlign(list->strbuf, sizeof(char) * list->strbuf_capacity, PU_STATIC, NULL, 8);
}
{
+42 -19
View File
@@ -1694,17 +1694,34 @@ static menuitem_t OP_MonitorToggleMenu[] =
static menuitem_t OP_SaturnMenu[] =
{
{IT_HEADER, NULL, "Saturn Options", NULL, 0},
{IT_STRING | IT_CVAR, NULL, "Serverqueue waittime", &cv_connectawaittime, 20},
//{IT_STRING | IT_CVAR, NULL, "Addon Download Speed", &cv_downloadspeed, 55}, //no idea why you would wanna change it anyways
{IT_STRING | IT_CVAR, NULL, "Show Minimap Names", &cv_showminimapnames, 30},
{IT_STRING | IT_CVAR, NULL, "Skin Select Spinning Speed", &cv_skinselectspin, 50},
{IT_STRING | IT_CVAR, NULL, "Serverqueue waittime", &cv_connectawaittime, 70},
{IT_STRING | IT_CVAR, NULL, "Small Position Number", &cv_smallpos, 90},
{IT_STRING | IT_CVAR, NULL, "No Midnight Channel Flicker", &cv_lessflicker, 110},
{IT_SUBMENU|IT_STRING, NULL, "Player distortion...", &OP_PlayerDistortDef, 130},
{IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 140},
{IT_STRING | IT_CVAR, NULL, "Input Display outside of RA", &cv_showinput, 60},
{IT_STRING | IT_CVAR, NULL, "V2-ish Speedometer", &cv_newspeedometer, 70},
{IT_STRING | IT_CVAR, NULL, "Show Lap Emblem", &cv_showlapemblem, 80},
{IT_STRING | IT_CVAR, NULL, "Small Position Number", &cv_smallpos, 90},
{IT_STRING | IT_CVAR, NULL, "No Midnight Channel Flicker", &cv_lessflicker, 100},
{IT_SUBMENU|IT_STRING, NULL, "Player distortion...", &OP_PlayerDistortDef, 115},
{IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 130},
{IT_SUBMENU|IT_STRING, NULL, "Saturn Credits", &OP_SaturnCreditsDef, 160}, // uwu
{IT_SUBMENU|IT_STRING, NULL, "Saturn Credits", &OP_SaturnCreditsDef, 145}, // uwu
};
enum
{
sm_header,
sm_waittime,
sm_skinselspeed,
sm_input,
sm_speedometer,
sm_pisschannel,
sm_distortionmenu,
sm_hudoffsets,
sm_credits,
};
static menuitem_t OP_PlayerDistortMenu[] =
@@ -1715,6 +1732,7 @@ static menuitem_t OP_PlayerDistortMenu[] =
{IT_STRING | IT_CVAR, NULL, "Slope rotation distance", &cv_sloperolldist, 35},
{IT_STRING | IT_CVAR, NULL, "Rotate players when sliptiding", &cv_sliptideroll, 50},
{IT_STRING | IT_CVAR, NULL, "Player stretch factor", &cv_gravstretch, 65},
{IT_STRING | IT_CVAR, NULL, "Squish Sound Effect", &cv_slamsound, 80},
};
enum
@@ -1748,25 +1766,27 @@ static menuitem_t OP_SaturnCreditsMenu[] =
{IT_HEADER, NULL, "Main Devs <3", NULL, 20},
{IT_STRING, NULL, "alufolie91 aka Alug", NULL, 30},
{IT_STRING, NULL, "Indev", NULL, 40},
{IT_STRING2+IT_SPACE, NULL, "alufolie91 aka Alug", NULL, 30},
{IT_STRING2+IT_SPACE, NULL, "Indev", NULL, 40},
{IT_HEADER, NULL, "Testers <3", NULL, 60},
{IT_STRING, NULL, "Sunflower aka AnimeSonic", NULL, 70},
{IT_STRING, NULL, "Yuz aka Yuzler", NULL, 80},
{IT_STRING, NULL, "Democrab", NULL, 90},
{IT_STRING, NULL, "EXpand aka Maver", NULL, 100},
{IT_STRING2+IT_SPACE, NULL, "Sunflower aka AnimeSonic", NULL, 70},
{IT_STRING2+IT_SPACE, NULL, "Yuz aka Yuzler", NULL, 80},
{IT_STRING2+IT_SPACE, NULL, "Democrab", NULL, 90},
{IT_STRING2+IT_SPACE, NULL, "EXpand aka Maver", NULL, 100},
{IT_HEADER, NULL, "Special Thanks <3", NULL, 120},
{IT_STRING, NULL, "xyzzy", NULL, 130},
{IT_STRING, NULL, "Haya", NULL, 140},
{IT_STRING, NULL, "Galactice", NULL, 150},
{IT_STRING, NULL, "Himie and", NULL, 160},
{IT_STRING, NULL, "The Moe Mansion / Birdhouse Team", NULL, 170},
{IT_STRING, NULL, "All of Sunflower's Garden", NULL, 180},
{IT_STRING2+IT_SPACE, NULL, "xyzzy", NULL, 130},
{IT_STRING2+IT_SPACE, NULL, "Haya", NULL, 140},
{IT_STRING2+IT_SPACE, NULL, "Galactice", NULL, 150},
{IT_STRING2+IT_SPACE, NULL, "Himie and", NULL, 160},
{IT_STRING2+IT_SPACE, NULL, "The Moe Mansion / Birdhouse Team", NULL, 170},
{IT_STRING2+IT_SPACE, NULL, "All of Sunflower's Garden", NULL, 180},
{IT_STRING+IT_SPACE, NULL, "", NULL, 190}, // dummy text
{IT_STRING, NULL, "", NULL, 200}, // dummy text II
};
static menuitem_t OP_BirdMenu[] =
@@ -3829,6 +3849,9 @@ void M_Init(void)
OP_VideoOptionsMenu[op_video_ogl].status = IT_DISABLED;
#endif
if (!found_extra_kart) // why bother?
OP_SaturnMenu[sm_speedometer].status = IT_GRAYEDOUT;
#ifndef NONET
CV_RegisterVar(&cv_serversort);
#endif
@@ -11053,7 +11076,7 @@ static void M_DrawJoystick(void)
compareval4 = cv_usejoystick4.value;
compareval3 = cv_usejoystick3.value;
compareval2 = cv_usejoystick2.value;
compareval = cv_usejoystick.value
compareval = cv_usejoystick.value;
#endif
if ((setupcontrolplayer == 4 && (i == compareval4))
+1 -1
View File
@@ -114,7 +114,7 @@ fixed_t P_RandomFixedD(const char *rfile, INT32 rline)
{
CONS_Printf("P_RandomFixed() at: %sp %d\n", rfile, rline);
#endif
return (INT32)((INT64)__internal_prng__());
return __internal_prng__();
}
/** Provides a random byte. Distribution is uniform.
+14 -13
View File
@@ -3792,12 +3792,11 @@ void P_NullPrecipThinker(precipmobj_t *mobj)
{
//(void)mobj;
mobj->precipflags &= ~PCF_THUNK;
R_ResetPrecipitationMobjInterpolationState(mobj);
}
void P_SnowThinker(precipmobj_t *mobj)
{
R_ResetPrecipitationMobjInterpolationState(mobj);
P_CycleStateAnimation((mobj_t *)mobj);
// adjust height
@@ -3810,8 +3809,6 @@ void P_SnowThinker(precipmobj_t *mobj)
void P_RainThinker(precipmobj_t *mobj)
{
R_ResetPrecipitationMobjInterpolationState(mobj);
P_CycleStateAnimation((mobj_t *)mobj);
if (mobj->state != &states[S_RAIN1])
@@ -3838,17 +3835,18 @@ void P_RainThinker(precipmobj_t *mobj)
}
// adjust height
if ((mobj->z += mobj->momz) <= mobj->floorz)
if ((mobj->z += mobj->momz) > mobj->floorz)
return;
// no splashes on sky or bottomless pits
if (mobj->precipflags & PCF_PIT)
{
// no splashes on sky or bottomless pits
if (mobj->precipflags & PCF_PIT)
mobj->z = mobj->ceilingz;
else
{
mobj->z = mobj->floorz;
P_SetPrecipMobjState(mobj, S_SPLASH1);
}
mobj->z = mobj->ceilingz;
return;
}
mobj->z = mobj->floorz;
P_SetPrecipMobjState(mobj, S_SPLASH1);
}
static void P_RingThinker(mobj_t *mobj)
@@ -9564,6 +9562,9 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
mobj->spriteyscale = mobj->realyscale;
mobj->spritexoffset = mobj->spriteyoffset = 0;
// Funni slam sound when landing
mobj->slamsoundtimer = 0;
// set subsector and/or block links
P_SetThingPosition(mobj);
I_Assert(mobj->subsector != NULL);
+11
View File
@@ -23,6 +23,7 @@
// We need the WAD data structure for Map things, from the THINGS lump.
#include "doomdata.h"
#include "doomtype.h"
// States are tied to finite states are tied to animation frames.
// Needs precompiled tables/data structures.
@@ -394,6 +395,16 @@ typedef struct mobj_s
boolean colorized; // Whether the mobj uses the rainbow colormap
boolean rollmodel; // OpenGL: Should this model rotate?
tic_t slamsoundtimer;
// saltyhop! hardcode edition
boolean salty_ready;
boolean salty_tapping;
fixed_t salty_zoffset;
fixed_t salty_momz;
boolean salty_jump;
boolean init_salty;
// WARNING: New fields must be added separately to savegame and Lua.
} mobj_t;
+1
View File
@@ -1984,6 +1984,7 @@ static void LoadMobjThinker(actionf_p1 thinker)
mobj->spritexscale = mobj->spriteyscale = mobj->old_spritexscale = mobj->old_spriteyscale = FRACUNIT;
mobj->realxscale = mobj->realyscale = FRACUNIT;
mobj->stretchslam = 0;
mobj->slamsoundtimer = 0;
mobj->sloperoll = mobj->reservezangle = mobj->reservexydir = 0;
+13 -8
View File
@@ -298,8 +298,8 @@ void R_InterpolateMobjState(mobj_t *mobj, fixed_t frac, interpmobjstate_t *out)
// Sprite offsets are not interpolated until we have a way to interpolate them explicitly in Lua.
// It seems existing mods visually break more often than not if it is interpolated.
out->spritexoffset = mobj->spritexoffset;
out->spriteyoffset = mobj->spriteyoffset;
//out->spritexoffset = mobj->spritexoffset;
//out->spriteyoffset = mobj->spriteyoffset;
out->subsector = R_PointInSubsector(out->x, out->y);
@@ -357,11 +357,12 @@ static void AddInterpolator(levelinterpolator_t* interpolator)
levelinterpolators_size *= 2;
}
levelinterpolators = Z_Realloc(
levelinterpolators = Z_ReallocAlign(
(void*) levelinterpolators,
sizeof(levelinterpolator_t*) * levelinterpolators_size,
PU_LEVEL,
NULL
NULL,
sizeof(levelinterpolator_t*) * 8
);
}
@@ -371,8 +372,11 @@ static void AddInterpolator(levelinterpolator_t* interpolator)
static levelinterpolator_t *CreateInterpolator(levelinterpolator_type_e type, thinker_t *thinker)
{
levelinterpolator_t *ret = (levelinterpolator_t*) Z_Calloc(
sizeof(levelinterpolator_t), PU_LEVEL, NULL
levelinterpolator_t *ret = (levelinterpolator_t*) Z_CallocAlign(
sizeof(levelinterpolator_t),
PU_LEVEL,
NULL,
sizeof(levelinterpolator_t) * 8
);
ret->type = type;
@@ -687,11 +691,12 @@ void R_AddMobjInterpolator(mobj_t *mobj)
interpolated_mobjs_capacity *= 2;
}
interpolated_mobjs = Z_Realloc(
interpolated_mobjs = Z_ReallocAlign(
interpolated_mobjs,
sizeof(mobj_t *) * interpolated_mobjs_capacity,
PU_LEVEL,
NULL
NULL,
64
);
}
+1
View File
@@ -160,6 +160,7 @@ static CV_PossibleValue_t drawdist_cons_t[] = {
static CV_PossibleValue_t drawdist_precip_cons_t[] = {
{256, "256"}, {512, "512"}, {768, "768"},
{1024, "1024"}, {1536, "1536"}, {2048, "2048"},
{3072, "3072"}, {4096, "4096"},
{0, "None"}, {0, NULL}};
static CV_PossibleValue_t fov_cons_t[] = {{5*FRACUNIT, "MIN"}, {178*FRACUNIT, "MAX"}, {0, NULL}};
+13 -12
View File
@@ -1796,17 +1796,6 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing)
return;
}
// okay, we can't return now except for vertical clipping... this is a hack, but weather isn't networked, so it should be ok
if (!(thing->precipflags & PCF_THUNK))
{
if (thing->precipflags & PCF_RAIN)
P_RainThinker(thing);
else
P_SnowThinker(thing);
thing->precipflags |= PCF_THUNK;
}
//SoM: 3/17/2000: Disregard sprites that are out of view..
gzt = interp.z + spritecachedinfo[lump].topoffset;
gz = gzt - spritecachedinfo[lump].height;
@@ -1814,7 +1803,7 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing)
if (thing->subsector->sector->cullheight)
{
if (R_DoCulling(thing->subsector->sector->cullheight, viewsector->cullheight, viewz, gz, gzt))
return;
goto weatherthink;
}
// store information in a vissprite
@@ -1878,6 +1867,18 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing)
vis->precip = true;
vis->vflip = false;
vis->isScaled = false;
weatherthink:
// okay... this is a hack, but weather isn't networked, so it should be ok
if (!(thing->precipflags & PCF_THUNK))
{
if (thing->precipflags & PCF_RAIN)
P_RainThinker(thing);
else
P_SnowThinker(thing);
thing->precipflags |= PCF_THUNK;
}
}
// R_AddSprites
-5
View File
@@ -138,11 +138,6 @@ typedef struct vissprite_s
angle_t centerangle; // for paper sprites
struct {
fixed_t tan; // The amount to shear the sprite vertically per row
INT32 offset; // The center of the shearing location offset from x1
} shear;
fixed_t texturemid;
patch_t *patch;
+54 -11
View File
@@ -54,6 +54,7 @@ static void SetChannelsNum(void);
static void Command_Tunes_f(void);
static void Command_RestartAudio_f(void);
static void Command_RestartMusic_f(void); //mhhhm amiga type filters here i come uwu
static void Command_ShowMusicCredit_f(void);
// Sound system toggles
#ifndef NO_MIDI
@@ -322,6 +323,7 @@ void S_RegisterSoundStuff(void)
COM_AddCommand("tunes", Command_Tunes_f);
COM_AddCommand("restartaudio", Command_RestartAudio_f);
COM_AddCommand("restartmusic", Command_RestartMusic_f);
COM_AddCommand("showmusiccredit", Command_ShowMusicCredit_f);
#if defined (macintosh) && !defined (HAVE_SDL) // mp3 playlist stuff
@@ -1514,18 +1516,16 @@ void S_InitMusicDefs(void)
S_LoadMusicDefs(i);
}
//
// S_ShowSpecifiedMusicCredit
// S_FindMusicCredit
//
// Display song's credit on screen
// Returns musicdef of specified song, or null if musicdef for it doesn't exist
//
void S_ShowSpecifiedMusicCredit(const char *musname)
musicdef_t *S_FindMusicCredit(const char *musname)
{
musicdef_t *def = musicdefstart;
if (!cv_songcredits.value || demo.rewinding)
return;
if (!def) // No definitions
return;
@@ -1533,15 +1533,38 @@ void S_ShowSpecifiedMusicCredit(const char *musname)
{
if (!stricmp(def->name, musname))
{
cursongcredit.def = def;
cursongcredit.anim = 5*TICRATE;
cursongcredit.x = 0;
cursongcredit.trans = NUMTRANSMAPS;
return;
return def;
}
else
def = def->next;
}
return NULL;
}
//
// S_ShowSpecifiedMusicCredit
//
// Display song's credit on screen
//
void S_ShowSpecifiedMusicCredit(const char *musname)
{
musicdef_t *def;
if (digital_disabled) return;
if (!cv_songcredits.value || demo.rewinding)
return;
def = S_FindMusicCredit(musname);
if (def)
{
cursongcredit.def = def;
cursongcredit.anim = 5*TICRATE;
cursongcredit.x = 0;
cursongcredit.trans = NUMTRANSMAPS;
}
}
//
@@ -2175,6 +2198,26 @@ static void Command_RestartMusic_f(void) //same as RestartAudio but only music g
S_RestartMusic();
}
static void Command_ShowMusicCredit_f(void)
{
const char *musname = music_name;
if (COM_Argc() > 1)
{
musname = COM_Argv(1);
}
else
{
S_ShowMusicCredit();
}
musicdef_t *def = S_FindMusicCredit(musname);
if (def) {
CONS_Printf("%.6s - %.255s\n", musname, def->source);
}
}
void GameSounds_OnChange(void)
{
if (M_CheckParm("-nosound") || M_CheckParm("-noaudio"))
+1
View File
@@ -172,6 +172,7 @@ extern musicdef_t *musicdefstart;
void S_LoadMusicDefs(UINT16 wadnum);
void S_InitMusicDefs(void);
musicdef_t *S_FindMusicCredit(const char *musname);
void S_ShowSpecifiedMusicCredit(const char *musname);
void S_ShowMusicCredit(void);
+22
View File
@@ -2155,6 +2155,28 @@ INT32 V_DrawPingNum(INT32 x, INT32 y, INT32 flags, INT32 num, const UINT8 *color
return x;
}
// Jaden: Draw a number using the position numbers.
//
void V_DrawRankNum(INT32 x, INT32 y, INT32 flags, INT32 num, INT32 digits, const UINT8 *colormap)
{
INT32 w = SHORT(ranknum[0]->width) - 1;
if (flags & V_NOSCALESTART)
w *= vid.dupx;
if (num < 0)
num = -num;
// draw the number
do
{
x -= (w - 1);
V_DrawFixedPatch(x << FRACBITS, y << FRACBITS, FRACUNIT, flags, ranknum[num % 10], colormap);
num /= 10;
} while (--digits);
}
// Write a string using the credit font
// NOTE: the text is centered for screens larger than the base width
//
+3
View File
@@ -216,6 +216,9 @@ INT32 V_DrawPingNum(INT32 x, INT32 y, INT32 flags, INT32 num, const UINT8 *color
INT32 V_LevelNameWidth(const char *string);
INT32 V_LevelNameHeight(const char *string);
// Rank numbers.
void V_DrawRankNum(INT32 x, INT32 y, INT32 flags, INT32 num, INT32 digits, const UINT8 *colormap);
void V_DrawCreditString(fixed_t x, fixed_t y, INT32 option, const char *string);
INT32 V_CreditStringWidth(const char *string);
+250 -252
View File
@@ -1,7 +1,7 @@
// SONIC ROBO BLAST 2
//-----------------------------------------------------------------------------
// Copyright (C) 2006 by Graue.
// Copyright (C) 2006-2023 by Sonic Team Junior.
// Copyright (C) 2006-2018 by Sonic Team Junior.
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
@@ -27,7 +27,6 @@
#include "doomdef.h"
#include "doomstat.h"
#include "r_patch.h"
#include "i_system.h" // I_GetFreeMem
#include "i_video.h" // rendermode
#include "z_zone.h"
@@ -50,11 +49,27 @@ static boolean Z_calloc = false;
//#define ZDEBUG2
#endif
struct memblock_s;
typedef struct
{
struct memblock_s *block; // Describing this memory
UINT32 id; // Should be ZONEID
} ATTRPACK memhdr_t;
// Some code might want aligned memory. Assume it wants memory n bytes
// aligned -- then we allocate n-1 extra bytes and return a pointer to
// the first byte aligned as requested.
// Thus, "real" is the pointer we get from malloc() and will free()
// later, but "hdr" is where the memhdr_t starts.
// For non-aligned allocations they will be the same.
typedef struct memblock_s
{
void *real;
memhdr_t *hdr;
void **user;
INT32 tag; // purgelevel
UINT32 id; // Should be ZONEID
size_t size; // including the header and blocks
size_t realsize; // size of real data only
@@ -65,41 +80,74 @@ typedef struct memblock_s
#endif
struct memblock_s *next, *prev;
} memblock_t;
} ATTRPACK memblock_t;
#define MEMORY(x) (void *)((uintptr_t)(x) + sizeof(memblock_t))
#define MEMBLOCK(x) (memblock_t *)((uintptr_t)(x) - sizeof(memblock_t))
#ifdef ZDEBUG
#define Ptr2Memblock(s, f) Ptr2Memblock2(s, f, __FILE__, __LINE__)
static memblock_t *Ptr2Memblock2(void *ptr, const char* func, const char *file, INT32 line)
#else
static memblock_t *Ptr2Memblock(void *ptr, const char* func)
#endif
{
memhdr_t *hdr;
memblock_t *block;
if (ptr == NULL)
return NULL;
#ifdef ZDEBUG2
CONS_Printf("%s %s:%d\n", func, file, line);
#endif
hdr = (memhdr_t *)((UINT8 *)ptr - sizeof *hdr);
#ifdef VALGRIND_MAKE_MEM_DEFINED
VALGRIND_MAKE_MEM_DEFINED(hdr, sizeof *hdr);
#endif
#ifdef VALGRIND_MEMPOOL_EXISTS
if (!VALGRIND_MEMPOOL_EXISTS(hdr->block))
{
#ifdef ZDEBUG
I_Error("%s: bad memblock from %s:%d", func, file, line);
#else
I_Error("%s: bad memblock", func);
#endif
}
#endif
if (hdr->id != ZONEID)
{
#ifdef ZDEBUG
I_Error("%s: wrong id from %s:%d", func, file, line);
#else
I_Error("%s: wrong id", func);
#endif
}
block = hdr->block;
#ifdef VALGRIND_MAKE_MEM_NOACCESS
VALGRIND_MAKE_MEM_NOACCESS(hdr, sizeof *hdr);
#endif
return block;
}
// both the head and tail of the zone memory block list
static memblock_t head;
//
// Function prototypes
//
static void Command_Memfree_f(void);
#ifdef ZDEBUG
static void Command_Memdump_f(void);
#endif
// --------------------------
// Zone memory initialisation
// --------------------------
/** Initialises zone memory.
* Used at game startup.
*
* \sa I_GetFreeMem, Command_Memfree_f, Command_Memdump_f
*/
void Z_Init(void)
{
size_t total, memfree;
UINT32 total, memfree;
memset(&head, 0x00, sizeof(head));
head.next = head.prev = &head;
memfree = I_GetFreeMem(&total)>>20;
CONS_Printf("System memory: %sMB - Free: %sMB\n", sizeu1(total>>20), sizeu2(memfree));
CONS_Printf("System memory: %uMB - Free: %uMB\n", total>>20, memfree);
// Note: This allocates memory. Watch out.
COM_AddCommand("memfree", Command_Memfree_f);
@@ -109,17 +157,6 @@ void Z_Init(void)
#endif
}
// ----------------------
// Zone memory allocation
// ----------------------
/** Frees allocated memory.
*
* \param ptr A pointer to allocated memory,
* assumed to have been allocated with Z_Malloc/Z_Calloc.
* \sa Z_FreeTags
*/
#ifdef ZDEBUG
void Z_Free2(void *ptr, const char *file, INT32 line)
#else
@@ -135,14 +172,10 @@ void Z_Free(void *ptr)
CONS_Debug(DBG_MEMORY, "Z_Free %s:%d\n", file, line);
#endif
block = MEMBLOCK(ptr);
#ifdef PARANOIA
if (block->id != ZONEID)
#ifdef ZDEBUG
I_Error("Z_Free at %s:%d: wrong id", file, line);
block = Ptr2Memblock2(ptr, "Z_Free", file, line);
#else
I_Error("Z_Free: wrong id");
#endif
block = Ptr2Memblock(ptr, "Z_Free");
#endif
#ifdef ZDEBUG
@@ -150,9 +183,11 @@ void Z_Free(void *ptr)
CONS_Debug(DBG_MEMORY, "Z_Free at %s:%d\n", file, line);
#endif
#ifdef HAVE_BLUA
// anything that isn't by lua gets passed to lua just in case.
if (block->tag != PU_LUA)
LUA_InvalidateUserdata(ptr);
#endif
// TODO: if zdebugging, make sure no other block has a user
// that is about to be freed.
@@ -161,27 +196,21 @@ void Z_Free(void *ptr)
if (block->user != NULL)
*block->user = NULL;
#ifdef VALGRIND_DESTROY_MEMPOOL
VALGRIND_DESTROY_MEMPOOL(block);
#endif
// Free the memory and get rid of the block.
free(block->real);
block->prev->next = block->next;
block->next->prev = block->prev;
free(block);
#ifdef VALGRIND_DESTROY_MEMPOOL
VALGRIND_DESTROY_MEMPOOL(block);
#endif
}
/** malloc() that doesn't accept failure.
*
* \param size Amount of memory to be allocated, in bytes.
* \return A pointer to the allocated memory.
*/
// malloc() that doesn't accept failure.
static void *xm(size_t size)
{
const size_t padedsize = size+sizeof (size_t);
void *p;
if (padedsize < size)/* overflow check */
I_Error("You are allocating memory too large!");
p = malloc(padedsize);
void *p = malloc(padedsize);
if (p == NULL)
{
@@ -191,6 +220,10 @@ static void *xm(size_t size)
if (p == NULL)
{
#if defined (_NDS) | defined (_PSP)
// Temporary-ish debugging measure
Command_Memfree_f();
#endif
I_Error("Out of memory allocating %s bytes", sizeu1(size));
}
}
@@ -198,18 +231,10 @@ static void *xm(size_t size)
return p;
}
/** The Z_MallocAlign function.
* Allocates a block of memory, adds it to a linked list so we can keep track of it.
*
* \param size Amount of memory to be allocated, in bytes.
* \param tag Purge tag.
* \param user The address of a pointer to the memory to be allocated.
* When the memory is freed by Z_Free later,
* the pointer at this address will then be automatically set to NULL.
* \param alignbits The alignment of the memory to be allocated, in bits. Can be 0.
* \note You can pass Z_Malloc() a NULL user if the tag is less than PU_PURGELEVEL.
* \sa Z_CallocAlign, Z_ReallocAlign
*/
// Z_Malloc
// You can pass Z_Malloc() a NULL user if the tag is less than
// PU_PURGELEVEL.
#ifdef ZDEBUG
void *Z_Malloc2(size_t size, INT32 tag, void *user, INT32 alignbits,
const char *file, INT32 line)
@@ -217,67 +242,75 @@ void *Z_Malloc2(size_t size, INT32 tag, void *user, INT32 alignbits,
void *Z_MallocAlign(size_t size, INT32 tag, void *user, INT32 alignbits)
#endif
{
size_t extrabytes = (1<<alignbits) - 1;
size_t padsize = 0;
memblock_t *block;
void *ptr;
(void)(alignbits); // no longer used, so silence warnings.
memhdr_t *hdr;
void *given;
size_t blocksize = extrabytes + sizeof *hdr + size;
#ifdef ZDEBUG2
CONS_Debug(DBG_MEMORY, "Z_Malloc %s:%d\n", file, line);
#endif
block = xm(sizeof (memblock_t) + size);
ptr = MEMORY(block);
I_Assert((intptr_t)ptr % sizeof (void *) == 0);
block = xm(sizeof *block);
#ifdef HAVE_VALGRIND
padsize += (1<<sizeof(size_t))*2;
#endif
ptr = xm(blocksize + padsize*2);
// This horrible calculation makes sure that "given" is aligned
// properly.
given = (void *)((size_t)((UINT8 *)ptr + extrabytes + sizeof *hdr + padsize/2)
& ~extrabytes);
// The mem header lives 'sizeof (memhdr_t)' bytes before given.
hdr = (memhdr_t *)((UINT8 *)given - sizeof *hdr);
#ifdef VALGRIND_CREATE_MEMPOOL
VALGRIND_CREATE_MEMPOOL(block, padsize, Z_calloc);
Z_calloc = false;
#endif
#ifdef VALGRIND_MEMPOOL_ALLOC
VALGRIND_MEMPOOL_ALLOC(block, hdr, size + sizeof *hdr);
#endif
block->next = head.next;
block->prev = &head;
head.next = block;
block->next->prev = block;
block->real = ptr;
block->hdr = hdr;
block->tag = tag;
block->user = NULL;
#ifdef ZDEBUG
block->ownerline = line;
block->ownerfile = file;
#endif
block->size = sizeof (memblock_t) + size;
block->size = blocksize;
block->realsize = size;
#ifdef VALGRIND_CREATE_MEMPOOL
VALGRIND_CREATE_MEMPOOL(block, size, Z_calloc);
#endif
hdr->id = ZONEID;
hdr->block = block;
block->id = ZONEID;
#ifdef VALGRIND_MAKE_MEM_NOACCESS
VALGRIND_MAKE_MEM_NOACCESS(hdr, sizeof *hdr);
#endif
if (user != NULL)
{
block->user = user;
*(void **)user = ptr;
*(void **)user = given;
}
else if (tag >= PU_PURGELEVEL)
I_Error("Z_Malloc: attempted to allocate purgable block "
"(size %s) with no user", sizeu1(size));
return ptr;
return given;
}
/** The Z_CallocAlign function.
* Allocates a block of memory, adds it to a linked list so we can keep track of it.
* Unlike Z_MallocAlign, this also initialises the bytes to zero.
*
* \param size Amount of memory to be allocated, in bytes.
* \param tag Purge tag.
* \param user The address of a pointer to the memory to be allocated.
* When the memory is freed by Z_Free later,
* the pointer at this address will then be automatically set to NULL.
* \param alignbits The alignment of the memory to be allocated, in bits. Can be 0.
* \note You can pass Z_Calloc() a NULL user if the tag is less than PU_PURGELEVEL.
* \sa Z_MallocAlign, Z_ReallocAlign
*/
#ifdef ZDEBUG
void *Z_Calloc2(size_t size, INT32 tag, void *user, INT32 alignbits, const char *file, INT32 line)
#else
@@ -294,26 +327,10 @@ void *Z_CallocAlign(size_t size, INT32 tag, void *user, INT32 alignbits)
#endif
}
/** The Z_ReallocAlign function.
* Reallocates a block of memory with a new size.
*
* \param ptr A pointer to allocated memory,
* assumed to have been allocated with Z_Malloc/Z_Calloc.
* If NULL, this function instead acts as a wrapper for Z_CallocAlign.
* \param size New size of memory block, in bytes.
* If zero, then the memory is freed and NULL is returned.
* \param tag New purge tag.
* \param user The address of a pointer to the memory to be reallocated.
* This can be a different user to the one originally assigned to the memory block.
* \param alignbits The alignment of the memory to be allocated, in bits. Can be 0.
* \return A pointer to the reallocated memory. Can be NULL if memory was freed.
* \note You can pass Z_Realloc() a NULL user if the tag is less than PU_PURGELEVEL.
* \sa Z_MallocAlign, Z_CallocAlign
*/
#ifdef ZDEBUG
void *Z_Realloc2(void *ptr, size_t size, INT32 tag, void *user, INT32 alignbits, const char *file, INT32 line)
#else
void *Z_ReallocAlign(void *ptr, size_t size, INT32 tag, void *user, INT32 alignbits)
void *Z_ReallocAlign(void *ptr, size_t size,INT32 tag, void *user, INT32 alignbits)
#endif
{
void *rez;
@@ -339,14 +356,10 @@ void *Z_ReallocAlign(void *ptr, size_t size, INT32 tag, void *user, INT32 alignb
#endif
}
block = MEMBLOCK(ptr);
#ifdef PARANOIA
if (block->id != ZONEID)
#ifdef ZDEBUG
I_Error("Z_ReallocAlign at %s:%d: wrong id", file, line);
block = Ptr2Memblock2(ptr, "Z_Realloc", file, line);
#else
I_Error("Z_ReallocAlign: wrong id");
#endif
block = Ptr2Memblock(ptr, "Z_Realloc");
#endif
if (block == NULL)
@@ -384,11 +397,6 @@ void *Z_ReallocAlign(void *ptr, size_t size, INT32 tag, void *user, INT32 alignb
return rez;
}
/** Frees all memory for a given set of tags.
*
* \param lowtag The lowest tag to consider.
* \param hightag The highest tag to consider.
*/
void Z_FreeTags(INT32 lowtag, INT32 hightag)
{
memblock_t *block, *next;
@@ -397,57 +405,28 @@ void Z_FreeTags(INT32 lowtag, INT32 hightag)
for (block = head.next; block != &head; block = next)
{
next = block->next; // get link before freeing
if (block->tag >= lowtag && block->tag <= hightag)
Z_Free(MEMORY(block));
Z_Free((UINT8 *)block->hdr + sizeof *block->hdr);
}
}
/** Iterates through all memory for a given set of tags.
*
* \param lowtag The lowest tag to consider.
* \param hightag The highest tag to consider.
* \param iterfunc The iterator function.
*/
void Z_IterateTags(INT32 lowtag, INT32 hightag, boolean (*iterfunc)(void *))
{
memblock_t *block, *next;
//
// Z_CheckMemCleanup
//
// TODO: Currently blocks >= PU_PURGELEVEL are freed every
// CLEANUPCOUNT. It might be better to keep track of
// the total size of all purgable memory and free it when the
// size exceeds some value.
//
// This was in Z_Malloc, but was freeing data at
// unsafe times. Now it is only called when it is safe
// to cleanup memory.
if (!iterfunc)
I_Error("Z_IterateTags: no iterator function was given");
for (block = head.next; block != &head; block = next)
{
next = block->next; // get link before possibly freeing
if (block->tag >= lowtag && block->tag <= hightag)
{
void *mem = MEMORY(block);
boolean free = iterfunc(mem);
if (free)
Z_Free(mem);
}
}
}
// -----------------
// Utility functions
// -----------------
// starting value of nextcleanup
#define CLEANUPCOUNT 2000
// number of function calls left before next cleanup
static INT32 nextcleanup = CLEANUPCOUNT;
/** This was in Z_Malloc, but was freeing data at
* unsafe times. Now it is only called when it is safe
* to cleanup memory.
*
* \todo Currently blocks >= PU_PURGELEVEL are freed every
* CLEANUPCOUNT. It might be better to keep track of
* the total size of all purgable memory and free it when the
* size exceeds some value.
*/
void Z_CheckMemCleanup(void)
{
if (nextcleanup-- == 0)
@@ -466,13 +445,15 @@ void Z_CheckMemCleanup(void)
void Z_CheckHeap(INT32 i)
{
memblock_t *block;
memhdr_t *hdr;
UINT32 blocknumon = 0;
void *given;
for (block = head.next; block != &head; block = block->next)
{
blocknumon++;
given = MEMORY(block);
hdr = block->hdr;
given = (UINT8 *)hdr + sizeof *hdr;
#ifdef ZDEBUG2
CONS_Debug(DBG_MEMORY, "block %u owned by %s:%d\n",
blocknumon, block->ownerfile, block->ownerline);
@@ -488,7 +469,7 @@ void Z_CheckHeap(INT32 i)
#ifdef ZDEBUG
, block->ownerfile, block->ownerline
#endif
);
);
}
#endif
if (block->user != NULL && *(block->user) != given)
@@ -501,7 +482,7 @@ void Z_CheckHeap(INT32 i)
#ifdef ZDEBUG
, block->ownerfile, block->ownerline
#endif
);
);
}
if (block->next->prev != block)
{
@@ -513,7 +494,7 @@ void Z_CheckHeap(INT32 i)
#ifdef ZDEBUG
, block->ownerfile, block->ownerline
#endif
);
);
}
if (block->prev->next != block)
{
@@ -525,9 +506,25 @@ void Z_CheckHeap(INT32 i)
#ifdef ZDEBUG
, block->ownerfile, block->ownerline
#endif
);
);
}
if (block->id != ZONEID)
#ifdef VALGRIND_MAKE_MEM_DEFINED
VALGRIND_MAKE_MEM_DEFINED(hdr, sizeof *hdr);
#endif
if (hdr->block != block)
{
I_Error("Z_CheckHeap %d: block %u"
#ifdef ZDEBUG
"(owned by %s:%d)"
#endif
" doesn't have linkback from allocated memory",
i, blocknumon
#ifdef ZDEBUG
, block->ownerfile, block->ownerline
#endif
);
}
if (hdr->id != ZONEID)
{
I_Error("Z_CheckHeap %d: block %u"
#ifdef ZDEBUG
@@ -537,37 +534,50 @@ void Z_CheckHeap(INT32 i)
#ifdef ZDEBUG
, block->ownerfile, block->ownerline
#endif
);
);
}
#ifdef VALGRIND_MAKE_MEM_NOACCESS
VALGRIND_MAKE_MEM_NOACCESS(hdr, sizeof *hdr);
#endif
}
}
// ------------------------
// Zone memory modification
// ------------------------
/** Changes a memory block's purge tag.
*
* \param ptr A pointer to allocated memory,
* assumed to have been allocated with Z_Malloc/Z_Calloc.
* \param tag The new tag.
* \sa Z_SetUser
*/
#ifdef PARANOIA
void Z_ChangeTag2(void *ptr, INT32 tag, const char *file, INT32 line)
#else
void Z_ChangeTag(void *ptr, INT32 tag)
void Z_ChangeTag2(void *ptr, INT32 tag)
#endif
{
memblock_t *block;
memhdr_t *hdr;
if (ptr == NULL)
return;
block = MEMBLOCK(ptr);
hdr = (memhdr_t *)((UINT8 *)ptr - sizeof *hdr);
#ifdef VALGRIND_MAKE_MEM_DEFINED
VALGRIND_MAKE_MEM_DEFINED(hdr, sizeof *hdr);
#endif
#ifdef VALGRIND_MEMPOOL_EXISTS
if (!VALGRIND_MEMPOOL_EXISTS(hdr->block))
{
#ifdef PARANOIA
if (block->id != ZONEID) I_Error("Z_ChangeTag at %s:%d: wrong id", file, line);
I_Error("Z_CT at %s:%d: bad memblock", file, line);
#else
I_Error("Z_CT: bad memblock");
#endif
}
#endif
#ifdef PARANOIA
if (hdr->id != ZONEID) I_Error("Z_CT at %s:%d: wrong id", file, line);
#endif
block = hdr->block;
#ifdef VALGRIND_MAKE_MEM_NOACCESS
VALGRIND_MAKE_MEM_NOACCESS(hdr, sizeof *hdr);
#endif
if (tag >= PU_PURGELEVEL && block->user == NULL)
@@ -577,48 +587,12 @@ void Z_ChangeTag(void *ptr, INT32 tag)
block->tag = tag;
}
/** Changes a memory block's user.
*
* \param ptr A pointer to allocated memory,
* assumed to have been allocated with Z_Malloc/Z_Calloc.
* \param newuser The new user for the memory block.
* \sa Z_ChangeTag
*/
#ifdef PARANOIA
void Z_SetUser2(void *ptr, void **newuser, const char *file, INT32 line)
#else
void Z_SetUser(void *ptr, void **newuser)
#endif
{
memblock_t *block;
if (ptr == NULL)
return;
block = MEMBLOCK(ptr);
#ifdef PARANOIA
if (block->id != ZONEID) I_Error("Z_SetUser at %s:%d: wrong id", file, line);
#endif
if (block->tag >= PU_PURGELEVEL && newuser == NULL)
I_Error("Internal memory management error: "
"tried to make block purgable but it has no owner");
block->user = (void*)newuser;
*newuser = ptr;
}
// -----------------
// Zone memory usage
// -----------------
/** Calculates memory usage for a given set of tags.
*
* \param lowtag The lowest tag to consider.
* \param hightag The highest tag to consider.
* \return Number of bytes currently allocated in the heap for the
* given tags.
* \sa Z_TagUsage
*/
size_t Z_TagsUsage(INT32 lowtag, INT32 hightag)
{
@@ -635,54 +609,45 @@ size_t Z_TagsUsage(INT32 lowtag, INT32 hightag)
return cnt;
}
// -----------------------
// Miscellaneous functions
// -----------------------
/** The function called by the "memfree" console command.
* Prints the memory being used by each part of the game to the console.
*/
static void Command_Memfree_f(void)
size_t Z_TagUsage(INT32 tagnum)
{
size_t freebytes, totalbytes;
return Z_TagsUsage(tagnum, tagnum);
}
void Command_Memfree_f(void)
{
UINT32 freebytes, totalbytes;
Z_CheckHeap(-1);
CONS_Printf("\x82%s", M_GetText("Memory Info\n"));
CONS_Printf(M_GetText("Total heap used : %7s KB\n"), sizeu1(Z_TotalUsage()>>10));
CONS_Printf(M_GetText("Static : %7s KB\n"), sizeu1(Z_TagUsage(PU_STATIC)>>10));
CONS_Printf(M_GetText("Static (sound) : %7s KB\n"), sizeu1(Z_TagUsage(PU_SOUND)>>10));
CONS_Printf(M_GetText("Static (music) : %7s KB\n"), sizeu1(Z_TagUsage(PU_MUSIC)>>10));
CONS_Printf(M_GetText("Locked cache : %7s KB\n"), sizeu1(Z_TagUsage(PU_CACHE)>>10));
CONS_Printf(M_GetText("Level : %7s KB\n"), sizeu1(Z_TagUsage(PU_LEVEL)>>10));
CONS_Printf(M_GetText("Special thinker : %7s KB\n"), sizeu1(Z_TagUsage(PU_LEVSPEC)>>10));
CONS_Printf(M_GetText("All purgable : %7s KB\n"),
CONS_Printf(M_GetText("Total heap used : %7s KB\n"), sizeu1(Z_TagsUsage(0, INT32_MAX)>>10));
CONS_Printf(M_GetText("Static : %7s KB\n"), sizeu1(Z_TagUsage(PU_STATIC)>>10));
CONS_Printf(M_GetText("Static (sound) : %7s KB\n"), sizeu1(Z_TagUsage(PU_SOUND)>>10));
CONS_Printf(M_GetText("Static (music) : %7s KB\n"), sizeu1(Z_TagUsage(PU_MUSIC)>>10));
CONS_Printf(M_GetText("Locked cache : %7s KB\n"), sizeu1(Z_TagUsage(PU_CACHE)>>10));
CONS_Printf(M_GetText("Level : %7s KB\n"), sizeu1(Z_TagUsage(PU_LEVEL)>>10));
CONS_Printf(M_GetText("Special thinker : %7s KB\n"), sizeu1(Z_TagUsage(PU_LEVSPEC)>>10));
CONS_Printf(M_GetText("All purgable : %7s KB\n"),
sizeu1(Z_TagsUsage(PU_PURGELEVEL, INT32_MAX)>>10));
#ifdef HWRENDER
if (rendermode != render_soft && rendermode != render_none)
{
CONS_Printf(M_GetText("Patch info headers : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRPATCHINFO)>>10));
CONS_Printf(M_GetText("Cached textures : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRCACHE)>>10));
CONS_Printf(M_GetText("Texture colormaps : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRPATCHCOLMIPMAP)>>10));
CONS_Printf(M_GetText("Plane polygons : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRPLANE)>>10));
CONS_Printf(M_GetText("All GPU textures : %7d KB\n"), HWR_GetTextureUsed()>>10);
CONS_Printf(M_GetText("Patch info headers: %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRPATCHINFO)>>10));
CONS_Printf(M_GetText("Mipmap patches : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRPATCHCOLMIPMAP)>>10));
CONS_Printf(M_GetText("HW Texture cache : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRCACHE)>>10));
CONS_Printf(M_GetText("Plane polygons : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRPLANE)>>10));
CONS_Printf(M_GetText("All GPU textures : %7d KB\n"), sizeu1(Z_TagUsage(HWR_GetTextureUsed())>>10));
}
#endif
CONS_Printf("\x82%s", M_GetText("System Memory Info\n"));
freebytes = I_GetFreeMem(&totalbytes);
CONS_Printf(M_GetText(" Total physical memory: %s KB\n"), sizeu1(totalbytes>>10));
CONS_Printf(M_GetText("Available physical memory: %s KB\n"), sizeu1(freebytes>>10));
CONS_Printf(M_GetText(" Total physical memory: %7u KB\n"), totalbytes>>10);
CONS_Printf(M_GetText("Available physical memory: %7u KB\n"), freebytes>>10);
}
#ifdef ZDEBUG
/** The function called by the "memdump" console command.
* Prints zone memory debugging information (i.e. tag, size, location in code allocated).
* Can be all memory allocated in game, or between a set of tags (if -min/-max args used).
* This command is available only if ZDEBUG is enabled.
*/
static void Command_Memdump_f(void)
{
memblock_t *block;
@@ -704,12 +669,45 @@ static void Command_Memdump_f(void)
}
#endif
/** Creates a copy of a string.
*
* \param s The string to be copied.
* \return A copy of the string, allocated in zone memory.
*/
// Creates a copy of a string.
char *Z_StrDup(const char *s)
{
return strcpy(ZZ_Alloc(strlen(s) + 1), s);
}
#ifdef PARANOIA
void Z_SetUser2(void *ptr, void **newuser, const char *file, INT32 line)
#else
void Z_SetUser2(void *ptr, void **newuser)
#endif
{
memblock_t *block;
memhdr_t *hdr;
if (ptr == NULL)
return;
hdr = (memhdr_t *)((UINT8 *)ptr - sizeof *hdr);
#ifdef VALGRIND_MAKE_MEM_DEFINED
VALGRIND_MAKE_MEM_DEFINED(hdr, sizeof *hdr);
#endif
#ifdef PARANOIA
if (hdr->id != ZONEID) I_Error("Z_CT at %s:%d: wrong id", file, line);
#endif
block = hdr->block;
#ifdef VALGRIND_MAKE_MEM_NOACCESS
VALGRIND_MAKE_MEM_NOACCESS(hdr, sizeof *hdr);
#endif
if (block->tag >= PU_PURGELEVEL && newuser == NULL)
I_Error("Internal memory management error: "
"tried to make block purgable but it has no owner");
block->user = (void*)newuser;
*newuser = ptr;
}
+64 -88
View File
@@ -2,7 +2,7 @@
//-----------------------------------------------------------------------------
// Copyright (C) 1993-1996 by id Software, Inc.
// Copyright (C) 1998-2000 by DooM Legacy Team.
// Copyright (C) 1999-2023 by Sonic Team Junior.
// Copyright (C) 1999-2018 by Sonic Team Junior.
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
@@ -15,7 +15,6 @@
#define __Z_ZONE__
#include <stdio.h>
#include "doomdef.h"
#include "doomtype.h"
#ifdef __GNUC__ // __attribute__ ((X))
@@ -31,120 +30,97 @@
//#define ZDEBUG
//
// Purge tags
//
// Now they are an enum! -- Monster Iestyn 15/02/18
//
enum
{
// Tags < PU_LEVEL are not purged until freed explicitly.
PU_STATIC = 1, // static entire execution time
PU_LUA = 2, // static entire execution time -- used by lua so it doesn't get caught in loops forever
PU_PERFSTATS = 3, // static between changes to ps_samplesize cvar
// ZONE MEMORY
// PU - purge tags.
// Tags < PU_LEVEL are not purged until freed explicitly.
#define PU_STATIC 1 // static entire execution time
#define PU_LUA 2 // static entire execution time -- used by lua so it doesn't get caught in loops forever
#define PU_PERFSTATS 3 // static between changes to ps_samplesize cvar
PU_SOUND = 11, // static while playing
PU_MUSIC = 12, // static while playing
PU_HUDGFX = 13, // static until WAD added
#define PU_SOUND 11 // static while playing
#define PU_MUSIC 12 // static while playing
#define PU_HUDGFX 13 // static until WAD added
PU_HWRPATCHINFO = 21, // Hardware GLPatch_t struct for OpenGL texture cache
PU_HWRPATCHCOLMIPMAP = 22, // Hardware GLMipmap_t struct colormap variation of patch
#define PU_HWRPATCHINFO 21 // Hardware GLPatch_t struct for OpenGL texture cache
#define PU_HWRPATCHCOLMIPMAP 22 // Hardware GLMipmap_t struct colromap variation of patch
PU_HWRCACHE = 48, // static until unlocked
PU_CACHE = 49, // static until unlocked
#define PU_HWRCACHE 48 // static until unlocked
#define PU_CACHE 49 // static until unlocked
// Tags s.t. PU_LEVEL <= tag < PU_PURGELEVEL are purged at level start
PU_LEVEL = 50, // static until level exited
PU_LEVSPEC = 51, // a special thinker in a level
PU_HWRPLANE = 52, // if ZPLANALLOC is enabled in hw_bsp.c, this is used to alloc polygons for OpenGL
// Tags s.t. PU_LEVEL <= tag < PU_PURGELEVEL are purged at level start
#define PU_LEVEL 50 // static until level exited
#define PU_LEVSPEC 51 // a special thinker in a level
#define PU_HWRPLANE 52
// Tags >= PU_PURGELEVEL are purgable whenever needed
PU_PURGELEVEL = 100, // Note: this is never actually used as a tag
PU_CACHE_UNLOCKED = 101, // Note: unused
PU_HWRCACHE_UNLOCKED = 102, // 'unlocked' PU_HWRCACHE memory:
// 'second-level' cache for graphics
// stored in hardware format and downloaded as needed
PU_HWRPATCHINFO_UNLOCKED = 103, // 'unlocked' PU_HWRMODELTEXTURE memory
};
// Tags >= PU_PURGELEVEL are purgable whenever needed
#define PU_PURGELEVEL 100
#define PU_CACHE_UNLOCKED 101
#define PU_HWRCACHE_UNLOCKED 102 // 'second-level' cache for graphics
// stored in hardware format and downloaded as needed
#define PU_HWRPATCHINFO_UNLOCKED 103
//
// Zone memory initialisation
//
void Z_Init(void);
void Z_FreeTags(INT32 lowtag, INT32 hightag);
void Z_CheckMemCleanup(void);
void Z_CheckHeap(INT32 i);
#ifdef PARANOIA
void Z_ChangeTag2(void *ptr, INT32 tag, const char *file, INT32 line);
#else
void Z_ChangeTag2(void *ptr, INT32 tag);
#endif
//
// Zone memory allocation
//
// enable ZDEBUG to get the file + line the functions were called from
// for ZZ_Alloc, see doomdef.h
//
#ifdef PARANOIA
void Z_SetUser2(void *ptr, void **newuser, const char *file, INT32 line);
#else
void Z_SetUser2(void *ptr, void **newuser);
#endif
// Z_Free and alloc with alignment
#ifdef ZDEBUG
#define Z_Free(p) Z_Free2(p, __FILE__, __LINE__)
#define Z_MallocAlign(s,t,u,a) Z_Malloc2(s, t, u, a, __FILE__, __LINE__)
#define Z_CallocAlign(s,t,u,a) Z_Calloc2(s, t, u, a, __FILE__, __LINE__)
#define Z_ReallocAlign(p,s,t,u,a) Z_Realloc2(p,s, t, u, a, __FILE__, __LINE__)
#define Z_Free(p) Z_Free2(p, __FILE__, __LINE__)
void Z_Free2(void *ptr, const char *file, INT32 line);
#define Z_Malloc(s,t,u) Z_Malloc2(s, t, u, 0, __FILE__, __LINE__)
#define Z_MallocAlign(s,t,u,a) Z_Malloc2(s, t, u, a, __FILE__, __LINE__)
void *Z_Malloc2(size_t size, INT32 tag, void *user, INT32 alignbits, const char *file, INT32 line) FUNCALLOC(1);
#define Z_Calloc(s,t,u) Z_Calloc2(s, t, u, 0, __FILE__, __LINE__)
#define Z_CallocAlign(s,t,u,a) Z_Calloc2(s, t, u, a, __FILE__, __LINE__)
void *Z_Calloc2(size_t size, INT32 tag, void *user, INT32 alignbits, const char *file, INT32 line) FUNCALLOC(1);
#define Z_Realloc(p,s,t,u) Z_Realloc2(p, s, t, u, 0, __FILE__, __LINE__)
#define Z_ReallocAlign(p,s,t,u,a) Z_Realloc2(p,s, t, u, a, __FILE__, __LINE__)
void *Z_Realloc2(void *ptr, size_t size, INT32 tag, void *user, INT32 alignbits, const char *file, INT32 line) FUNCALLOC(2);
#else
void Z_Free(void *ptr);
void *Z_MallocAlign(size_t size, INT32 tag, void *user, INT32 alignbits) FUNCALLOC(1);
#define Z_Malloc(s,t,u) Z_MallocAlign(s, t, u, 0)
void *Z_CallocAlign(size_t size, INT32 tag, void *user, INT32 alignbits) FUNCALLOC(1);
void *Z_ReallocAlign(void *ptr, size_t size, INT32 tag, void *user, INT32 alignbits) FUNCALLOC(2);
#define Z_Calloc(s,t,u) Z_CallocAlign(s, t, u, 0)
void *Z_ReallocAlign(void *ptr, size_t size, INT32 tag, void *user, INT32 alignbits) FUNCALLOC(2) ;
#define Z_Realloc(p, s,t,u) Z_ReallocAlign(p, s, t, u, 0)
#endif
// Alloc with standard alignment
#define Z_Malloc(s,t,u) Z_MallocAlign(s, t, u, sizeof(void *))
#define Z_Calloc(s,t,u) Z_CallocAlign(s, t, u, sizeof(void *))
#define Z_Realloc(p,s,t,u) Z_ReallocAlign(p, s, t, u, sizeof(void *))
size_t Z_TagUsage(INT32 tagnum);
size_t Z_TagsUsage(INT32 lowtag, INT32 hightag);
// Free all memory by tag
// these don't give line numbers for ZDEBUG currently though
// (perhaps this should be changed in future?)
#define Z_FreeTag(tagnum) Z_FreeTags(tagnum, tagnum)
void Z_FreeTags(INT32 lowtag, INT32 hightag);
char *Z_StrDup(const char *in);
// Iterate memory by tag
#define Z_IterateTag(tagnum, func) Z_IterateTags(tagnum, tagnum, func)
void Z_IterateTags(INT32 lowtag, INT32 hightag, boolean (*iterfunc)(void *));
//
// Utility functions
//
void Z_CheckMemCleanup(void);
void Z_CheckHeap(INT32 i);
//
// Zone memory modification
//
// enable PARANOIA to get the file + line the functions were called from
// This is used to get the local FILE : LINE info from CPP
// prior to really call the function in question.
//
#ifdef PARANOIA
#define Z_ChangeTag(p,t) Z_ChangeTag2(p, t, __FILE__, __LINE__)
#define Z_SetUser(p,u) Z_SetUser2(p, u, __FILE__, __LINE__)
void Z_ChangeTag2(void *ptr, INT32 tag, const char *file, INT32 line);
void Z_SetUser2(void *ptr, void **newuser, const char *file, INT32 line);
#else
void Z_ChangeTag(void *ptr, INT32 tag);
void Z_SetUser(void *ptr, void **newuser);
#define Z_ChangeTag(p,t) Z_ChangeTag2(p, t)
#endif
//
// Zone memory usage
//
// Note: These give the memory used in bytes,
// shift down by 10 to convert to KB
//
#define Z_TagUsage(tagnum) Z_TagsUsage(tagnum, tagnum)
size_t Z_TagsUsage(INT32 lowtag, INT32 hightag);
#define Z_TotalUsage() Z_TagsUsage(0, INT32_MAX)
#ifdef PARANOIA
#define Z_SetUser(p,u) Z_SetUser2(p, u, __FILE__, __LINE__)
#else
#define Z_SetUser(p,u) Z_SetUser2(p, u)
#endif
//
// Miscellaneous functions
//
char *Z_StrDup(const char *in);
#define Z_Unlock(p) (void)p // TODO: remove this now that NDS code has been removed
#ifdef _NDS ///TODO: need a lock reference system
#define Z_Unlock(p) Z_ChangeTag(p, PU_CACHE_UNLOCKED)
#else
#define Z_Unlock(p) (void)p
#endif
#endif