Page 1 of 1

Unlimited ammo collection

Posted: Fri Mar 06, 2009 2:47 pm
by Hirogen2
I found this little feature a good aid for testing (single-player) maps on whether their ammo balance is right. Play through, for example, ED4_RFO1 MAP13, attempting to score >90% kills, and you will notice that you have in the excess of 2000 bullets/shells when you are done. Of course it depends on the particular player, but I'm just sayin' that if you play through MAP27, you end the level with moderate amounts of ammo, indicating the balance is good.

Re: Unlimited ammo collection

Posted: Fri Mar 06, 2009 3:25 pm
by Graf Zahl
I can't merge this patch. Apparently its format is incompatible with TortoiseSVN.

Re: Unlimited ammo collection

Posted: Fri Mar 06, 2009 3:33 pm
by Macil
The diff file doesn't look like it was made by the svn diff tool, and it doesn't seem to be compatible with the diff tool on my linux computer, using an unknown "--git" option. (Obviously the code is human-readable and doesn't seem too hard to do by hand, just a bit trivial.)

@Hirogen: To make an svn diff file, just use the command "svn diff" (and write it to a file, eg "svn diff > mychanges.diff").


EDIT: I added it to my post in the svn diff format.

Re: Unlimited ammo collection

Posted: Fri Mar 06, 2009 3:57 pm
by Hirogen2
I do not see anything “wrong” with the patch. Though made by git, it conforms to unidiff.

Code: Select all

22:55 yaguchi:../zdoom/zdoom-2.3.0 > patch -p1 --dry </dev/shm/ulp.diff.txt 
patching file src/c_cmds.cpp
patching file src/d_main.cpp
Hunk #2 succeeded at 2370 (offset -12 lines).
patching file src/g_shared/a_pickups.cpp
patching file src/g_shared/a_weapons.cpp
Are you suggesting that tortoise cannot handle unidiff?

Re: Unlimited ammo collection

Posted: Fri Mar 06, 2009 4:21 pm
by Gez
Try this instead. I think it should work.

Code: Select all

--- src/c_cmds.cpp	(revision 1463)
+++ src/c_cmds.cpp	(working copy)
@@ -73,6 +73,7 @@ extern FILE *Logfile;
 	extern bool insave;
 
 	CVAR (Bool, sv_cheats, false, CVAR_SERVERINFO | CVAR_LATCH)
+	CVAR (Bool, sv_unlimited_pickup, false, CVAR_ARCHIVE | CVAR_SERVERINFO)
 
 	CCMD (toggleconsole)
 	{

--- src/d_main.cpp	(revision 1463)
+++ src/d_main.cpp	(working copy)
@@ -143,6 +143,7 @@ EXTERN_CVAR (Bool, invertmouse)
 	EXTERN_CVAR (Bool, lookstrafe)
 	EXTERN_CVAR (Int, screenblocks)
 	EXTERN_CVAR (Bool, sv_cheats)
+	EXTERN_CVAR (Bool, sv_unlimited_pickup)
 	
 	extern gameinfo_t SharewareGameInfo;
 	extern gameinfo_t RegisteredGameInfo;
@@ -2381,6 +2382,7 @@ void D_DoomMain (void)
 	if (Args->CheckParm ("-nomonsters"))	flags |= DF_NO_MONSTERS;
 	if (Args->CheckParm ("-respawn"))		flags |= DF_MONSTERS_RESPAWN;
 	if (Args->CheckParm ("-fast"))			flags |= DF_FAST_MONSTERS;
+	if (Args->CheckParm("-ulp"))	sv_unlimited_pickup = true;
 	
 	devparm = !!Args->CheckParm ("-devparm");
 
--- src/g_shared/a_pickups.cpp	(revision 1463)
+++ src/g_shared/a_pickups.cpp	(working copy)
@@ -67,13 +67,14 @@ const PClass *AAmmo::GetParentAmmo () const
 	// AAmmo :: HandlePickup
 	//
 	//===========================================================================
+	EXTERN_CVAR(Bool, sv_unlimited_pickup)
 	
 	bool AAmmo::HandlePickup (AInventory *item)
 	{
 		if (GetClass() == item->GetClass() ||
 			(item->IsKindOf (RUNTIME_CLASS(AAmmo)) && static_cast<AAmmo*>(item)->GetParentAmmo() == GetClass()))
 		{
-			if (Amount < MaxAmount)
+			if (Amount < MaxAmount || sv_unlimited_pickup)
 			{
 				int receiving = item->Amount;
 
@@ -84,7 +85,7 @@ bool AAmmo::HandlePickup (AInventory *item)
 				int oldamount = Amount;
 				
 				Amount += receiving;
-				if (Amount > MaxAmount)
+				if (Amount > MaxAmount && !sv_unlimited_pickup)
 				{
 					Amount = MaxAmount;
 				}

--- src/g_shared/a_weapons.cpp	(revision 1463)
+++ src/g_shared/a_weapons.cpp	(working copy)
@@ -326,10 +326,11 @@ AAmmo *AWeapon::AddAmmo (AActor *other, const PClass *ammotype, int amount)
 	// Give the owner some more ammo he already has.
 	//
 	//===========================================================================
+	EXTERN_CVAR(Bool, sv_unlimited_pickup)
 	
 	bool AWeapon::AddExistingAmmo (AAmmo *ammo, int amount)
 	{
-		if (ammo != NULL && ammo->Amount < ammo->MaxAmount)
+		if (ammo != NULL && (ammo->Amount < ammo->MaxAmount || sv_unlimited_pickup))
 		{
 			// extra ammo in baby mode and nightmare mode
 			if (!(ItemFlags&IF_IGNORESKILL))
@@ -337,7 +338,7 @@ bool AWeapon::AddExistingAmmo (AAmmo *ammo, int amount)
 				amount = FixedMul(amount, G_SkillProperty(SKILLP_AmmoFactor));
 			}
 			ammo->Amount += amount;
-			if (ammo->Amount > ammo->MaxAmount)
+			if (ammo->Amount > ammo->MaxAmount && !sv_unlimited_pickup)
 			{
 				ammo->Amount = ammo->MaxAmount;
 			}

Re: Unlimited ammo collection

Posted: Fri Mar 06, 2009 4:29 pm
by Graf Zahl
Please post it as attachment. I don't trust patches in code tags.

Re: Unlimited ammo collection

Posted: Fri Mar 06, 2009 4:49 pm
by Macil
Hirogen2 wrote:Are you suggesting that tortoise cannot handle unidiff?
It's probably because maybe TortoiseSVN didn't run the diff with the "-p1" option. SVN's diff format doesn't need this.

I posted an attachment of this diff file in svn's format in my previous post. http://forum.zdoom.org/download/file.php?id=6683

Re: Unlimited ammo collection

Posted: Sat Mar 07, 2009 6:27 pm
by randi
Is this something that should really be stored in the config? The fact that you provided a command-line option to turn it on but not one to turn it off suggests it shouldn't be.

Re: Unlimited ammo collection

Posted: Fri May 15, 2009 12:03 pm
by Hirogen2
Should probably remove the command line option then.
Config file.. you would not think about a config file with a flag named "ARCHIVE" (cf. when FArchive being related to savegames).

Re: Unlimited ammo collection

Posted: Fri May 15, 2009 1:34 pm
by HotWax
I disagree. This feature is clearly a cheat / debug tool and shouldn't be saved as a player option.

Re: Unlimited ammo collection

Posted: Fri May 15, 2009 3:04 pm
by Hirogen2
HotWax wrote:I disagree. This feature is clearly a cheat / debug tool and shouldn't be saved as a player option.
That is what I said, or meant. “CVAR_ARCHIVE” misled, but Graf Zahl was already kind enough to spot this and CVAR_ARCHIVE was soon removed so it does not get stored in zdoom.ini.