* Updated to ZDoom 4025:

- Do not clear the CF_WEAPONSWITCHOK flag each tic, so that the last setting from A_WeaponReady will carry over until the next A_WeaponReady. Changed P_CheckWeaponSwitch() to clear any pending weapon requests while weapon switching is disabled.
- Removed the BuildString() override that took a char** argv, because it was used nowhere.
- Fixed: BuildString() failed to properly generate command lines for arguments with embedded " characters.

git-svn-id: http://mancubus.net/svn/hosted/gzdoom/trunk@1505 b0f79afe-0144-0410-b225-9a4edf0717df
This commit is contained in:
gez 2013-01-12 14:29:18 +00:00
parent bfc35bab40
commit a7dcb7c6e8
4 changed files with 57 additions and 48 deletions

View file

@ -1019,32 +1019,7 @@ FConsoleAlias::~FConsoleAlias ()
m_Command[1] = m_Command[0] = FString();
}
FString BuildString (int argc, char **argv)
{
if (argc == 1)
{
return *argv;
}
else
{
FString buf;
int arg;
for (arg = 0; arg < argc; arg++)
{
if (strchr (argv[arg], ' '))
{
buf.AppendFormat ("\"%s\" ", argv[arg]);
}
else
{
buf.AppendFormat ("%s ", argv[arg]);
}
}
return buf;
}
}
// Given an argument vector, reconstitute the command line it could have been produced from.
FString BuildString (int argc, FString *argv)
{
if (argc == 1)
@ -1058,8 +1033,23 @@ FString BuildString (int argc, FString *argv)
for (arg = 0; arg < argc; arg++)
{
if (strchr (argv[arg], ' '))
{
if (strchr(argv[arg], '"'))
{ // If it contains one or more quotes, we need to escape them.
buf << '"';
long substr_start = 0, quotepos;
while ((quotepos = argv[arg].IndexOf('"', substr_start)) >= 0)
{
if (substr_start < quotepos)
{
buf << argv[arg].Mid(substr_start, quotepos - substr_start);
}
buf << "\\\"";
substr_start = quotepos + 1;
}
buf << argv[arg].Mid(substr_start) << "\" ";
}
else if (strchr(argv[arg], ' '))
{ // If it contains a space, it needs to be quoted.
buf << '"' << argv[arg] << "\" ";
}
else

View file

@ -61,7 +61,6 @@ void C_SetAlias (const char *name, const char *cmd);
void C_ClearAliases ();
// build a single string out of multiple strings
FString BuildString (int argc, char **argv);
FString BuildString (int argc, FString *argv);
// Class that can parse command lines

View file

@ -95,7 +95,7 @@ void P_SetPsprite (player_t *player, int position, FState *state, bool nofunctio
if (position == ps_weapon && !nofunction)
{ // A_WeaponReady will re-set these as needed
player->cheats &= ~(CF_WEAPONREADY | CF_WEAPONREADYALT | CF_WEAPONBOBBING | CF_WEAPONSWITCHOK | CF_WEAPONRELOADOK | CF_WEAPONZOOMOK);
player->cheats &= ~(CF_WEAPONREADY | CF_WEAPONREADYALT | CF_WEAPONBOBBING | CF_WEAPONRELOADOK | CF_WEAPONZOOMOK);
}
psp = &player->psprites[position];
@ -565,12 +565,30 @@ DEFINE_ACTION_FUNCTION_PARAMS(AInventory, A_WeaponReady)
ACTION_PARAM_START(1);
ACTION_PARAM_INT(paramflags, 0);
if (!(paramflags & WRF_NoSwitch)) DoReadyWeaponToSwitch(self);
if ((paramflags & WRF_NoFire) != WRF_NoFire) DoReadyWeaponToFire(self,
(!(paramflags & WRF_NoPrimary)), (!(paramflags & WRF_NoSecondary)));
if (!(paramflags & WRF_NoBob)) DoReadyWeaponToBob(self);
if ((paramflags & WRF_AllowReload)) DoReadyWeaponToReload(self);
if ((paramflags & WRF_AllowZoom)) DoReadyWeaponToZoom(self);
if (!(paramflags & WRF_NoSwitch))
{
DoReadyWeaponToSwitch(self);
}
else if (self->player != NULL)
{
self->player->cheats &= ~CF_WEAPONSWITCHOK;
}
if ((paramflags & WRF_NoFire) != WRF_NoFire)
{
DoReadyWeaponToFire(self, !(paramflags & WRF_NoPrimary), !(paramflags & WRF_NoSecondary));
}
if (!(paramflags & WRF_NoBob))
{
DoReadyWeaponToBob(self);
}
if ((paramflags & WRF_AllowReload))
{
DoReadyWeaponToReload(self);
}
if ((paramflags & WRF_AllowZoom))
{
DoReadyWeaponToZoom(self);
}
}
//---------------------------------------------------------------------------
@ -631,15 +649,20 @@ void P_CheckWeaponSwitch (player_t *player)
if (!player || !(weapon = player->ReadyWeapon))
return;
// Put the weapon away if the player has a pending weapon or has died.
if ((player->morphTics == 0 && player->PendingWeapon != WP_NOCHANGE) || player->health <= 0)
{
if (player->health <= 0)
{ // Dead, so put the weapon away.
P_SetPsprite(player, ps_weapon, weapon->GetDownState());
}
else if (!(player->cheats & CF_WEAPONSWITCHOK))
{ // Weapon changing has been disabled.
player->PendingWeapon = WP_NOCHANGE;
}
else if (player->morphTics == 0 && player->PendingWeapon != WP_NOCHANGE)
{ // Put the weapon away if the player has a pending weapon
P_SetPsprite (player, ps_weapon, weapon->GetDownState());
return;
}
else if (player->morphTics != 0)
{
// morphed classes cannot change weapons so don't even try again.
{ // Morphed classes cannot change weapons, so don't even try again.
player->PendingWeapon = WP_NOCHANGE;
}
}
@ -1052,10 +1075,7 @@ void P_MovePsprites (player_t *player)
}
player->psprites[ps_flash].sx = player->psprites[ps_weapon].sx;
player->psprites[ps_flash].sy = player->psprites[ps_weapon].sy;
if (player->cheats & CF_WEAPONSWITCHOK)
{
P_CheckWeaponSwitch (player);
}
P_CheckWeaponSwitch (player);
if (player->cheats & (CF_WEAPONREADY | CF_WEAPONREADYALT))
{
P_CheckWeaponFire (player);

View file

@ -3,5 +3,5 @@
// This file was automatically generated by the
// updaterevision tool. Do not edit by hand.
#define ZD_SVN_REVISION_STRING "4023"
#define ZD_SVN_REVISION_NUMBER 4023
#define ZD_SVN_REVISION_STRING "4025"
#define ZD_SVN_REVISION_NUMBER 4025