Makefile: add vacuum target.

Util_ChangeExtension: will handle a sensible fallback case now
NSItem: query MaxHealth, MaxArmor properly.
This commit is contained in:
Marco Cawthorne 2024-10-17 02:15:35 -07:00
parent 81d61ac3da
commit af708c1e90
11 changed files with 54 additions and 11 deletions

View file

@ -134,6 +134,18 @@ trshaders:
Tools/make_trshaders.sh $(GAME)
# recycling center
vacuum:
-rm ./$(GAME)/csqccore.txt
-rm ./$(GAME)/ssqccore.txt
-rm ./$(GAME)/menucore.txt
-rm ./$(GAME)/condump.txt
-rm ./$(GAME)/fte.cfg
-rm ./$(GAME)/config.cfg
-rm ./$(GAME)/*.lno
-rm -rfv ./$(GAME)/csprogsvers
-rm -rfv ./$(GAME)/data
-rm -rfv ./$(GAME)/saves
clean: clean-game clean-engine clean-tools clean-dist
clean-dist:
@ -162,6 +174,9 @@ clean-tools:
cd ThirdParty/fteqw/engine && $(MAKE) clean
-rm vmap vvmtool iqmtool imgtool fteqcc generatebuiltinsl makevulkanblob
debug:
gdb --args ./$(GAME_BINARY) +set sv_cheats 1 +set sv_csqcdebug 1 +set g_logLevel 3 +set g_logTimestamps 1
update:
if [ -f ./.git/config ];then git pull;fi
if [ -f $(GAME)/.git/config ];then cd $(GAME) && git pull;fi

View file

@ -28,7 +28,7 @@ void UI_CustomGame_Show ( void )
}
static void CustomGame_ScrollUpdate ( void ) {
scrlGames.SetValue( lsbGames.GetOffset(), FALSE );
scrlGames.SetValue( lsbGames.GetOffset() );
}
static void CustomGame_ListUpdate ( void ) {
lsbGames.SetOffset( scrlGames.GetValue(), FALSE );

View file

@ -30,7 +30,7 @@ void UI_LoadGame_Show ( void )
}
static void LoadGame_ScrollUpdate ( void ) {
scrlSaves.SetValue( lsbSaves.GetOffset(), FALSE );
scrlSaves.SetValue( lsbSaves.GetOffset() );
}
static void LoadGame_ListUpdate ( void ) {
lsbSaves.SetOffset( scrlSaves.GetValue(), FALSE );

View file

@ -245,7 +245,7 @@ void UI_ModelViewer_Show ( void )
}
static void ModelViewer_ScrollUpdate ( void ) {
scrlModels.SetValue( lstModels.GetOffset(), FALSE );
scrlModels.SetValue( lstModels.GetOffset() );
}
static void ModelViewer_ListUpdate ( void ) {
lstModels.SetOffset( scrlModels.GetValue(), FALSE );

View file

@ -33,7 +33,7 @@ void UI_MusicPlayer_Show ( void )
localcmd( "stopsound\n" );
}
static void MusicPlayer_ScrollUpdate ( void ) {
scrlSong.SetValue( lsbSongs.GetOffset(), FALSE );
scrlSong.SetValue( lsbSongs.GetOffset() );
}
static void MusicPlayer_ListUpdate ( void ) {
lsbSongs.SetOffset( scrlSong.GetValue(), FALSE );

View file

@ -22,7 +22,7 @@ MapC_Init(void)
string mapProgs;
/* mapname global is not set yet in init() */
mapProgs = sprintf("maps/%s.dat", cvar_string("mapname"));
mapProgs = Util_ChangeExtension(strcat("maps/", cvar_string("mapname")), "dat");
/* No mapname.dat, exit out */
if (fileExists(mapProgs) == false) {

View file

@ -235,13 +235,13 @@ NSItem::ItemPickupCheck(entity pickerUpper)
}
if (m_iGiveHealth > 0i) {
if (pl.GetHealth() < 100) {
if (pl.GetHealth() < pl.GetMaxHealth()) {
return (true);
}
}
if (m_iGiveArmor > 0i) {
if (pl.armor < 100) {
if (pl.armor < pl.GetMaxArmor()) {
return (true);
}
}

View file

@ -128,6 +128,11 @@ public:
/** Returns the current armor of the entity. */
nonvirtual float GetArmor(void);
/** Sets the maximum amount of armor the entity can have */
nonvirtual void SetMaxArmor(float);
/** Returns the maximum armor value the entity can have. */
nonvirtual float GetMaxArmor(void);
/** Returns the health the entity spawned with at map load */
nonvirtual float GetSpawnHealth(void);
/** Returns if the entity has prop data information set. */
@ -166,6 +171,8 @@ private:
PREDICTED_FLOAT_N(health)
#ifdef SERVER
float max_armor;
/* fire/burning */
entity m_eBurner;
int m_iBurnWeapon;

View file

@ -158,16 +158,31 @@ NSSurfacePropEntity::SetMaxHealth(float new_health)
health = min(health, max_health);
}
void
NSSurfacePropEntity::SetMaxArmor(float new_armor)
{
max_armor = new_armor;
armor = min(armor, max_armor);
}
float
NSSurfacePropEntity::GetHealth(void)
{
return (health);
}
float
NSSurfacePropEntity::GetMaxHealth(void)
{
return (max_health);
}
float
NSSurfacePropEntity::GetMaxArmor(void)
{
return (max_armor);
}
float
NSSurfacePropEntity::GetSpawnHealth(void)
{
@ -179,6 +194,7 @@ NSSurfacePropEntity::SetArmor(float new_armor)
{
armor = new_armor;
}
float
NSSurfacePropEntity::GetArmor(void)
{

View file

@ -185,7 +185,6 @@ enumflags
.vector basevelocity;
.float gflags;
.float identity;
.bool _isWeapon;
.bool _isItem;
@ -473,7 +472,8 @@ string Util_FixModel(string mdl)
}
/** Returns a string (usually filename) with only the file extension
at the end replaced with a given, new extension. */
at the end replaced with a given, new extension.
If the base string does not contain a file extension, it'll be appended to the end result. */
string
Util_ChangeExtension(string baseString, string newExtension)
{
@ -492,6 +492,11 @@ Util_ChangeExtension(string baseString, string newExtension)
stringOffset++;
}
/* no extension found? append to the end then. */
if (foundOffset == 0) {
return strcat(baseString, ".", newExtension);
}
return strcat(substring(baseString, 0, foundOffset), ".", newExtension);
}

View file

@ -229,7 +229,7 @@ NSPMoveVars::UpdateBoundingBoxes(void)
void
NSPMoveVars::Refresh(void)
{
printf("Refreshing pmove Vars %S\n", m_defLink);
// printf("Refreshing pmove Vars %S\n", m_defLink);
/* global. */
if (!STRING_SET(m_defLink)) {
@ -574,7 +574,7 @@ NSPMoveVars::ReceiveEntity(float flNew, float flChanged)
g_pmoveVars = this;
}
printf("Refreshing all pmove vars.\n");
// printf("Refreshing all pmove vars.\n");
for (NSPMoveVars vars = __NULL__;(vars = (NSPMoveVars)find(vars, ::classname, "NSPMoveVars"));) {
vars.Refresh();