- Fixed: The correct player class was not remembered when the menu had both

a player class selection menu and an episode menu.
- Fixed: AddToConsole could write outside its working buffer.
- Fixed: 0 was no longer recognized as placeholder for 'no state' in A_Chase.
- Fixed: When picking up weapons the code did not check if it should switch away
  from weak weapons.


SVN r1332 (trunk)
This commit is contained in:
Christoph Oelckers 2008-12-27 20:18:31 +00:00
parent a66eb7f8c3
commit 37d056c041
8 changed files with 73 additions and 16 deletions

View file

@ -1,3 +1,11 @@
December 27, 2008 (Changes by Graf Zahl)
- Fixed: The correct player class was not remembered when the menu had both
a player class selection menu and an episode menu.
- Fixed: AddToConsole could write outside its working buffer.
- Fixed: 0 was no longer recognized as placeholder for 'no state' in A_Chase.
- Fixed: When picking up weapons the code did not check if it should switch away
from weak weapons.
December 20, 2008 December 20, 2008
- OggMod improperly decodes the right channel of stereo samples when sending - OggMod improperly decodes the right channel of stereo samples when sending
them to OggEnc, so I have no choice but to convert them to mono by chopping them to OggEnc, so I have no choice but to convert them to mono by chopping

View file

@ -667,7 +667,7 @@ void AddToConsole (int printlevel, const char *text)
} }
len = (int)strlen (text); len = (int)strlen (text);
size = len + 3; size = len + 20;
if (addtype != NEWLINE) if (addtype != NEWLINE)
{ {
@ -767,6 +767,15 @@ void AddToConsole (int printlevel, const char *text)
if (*work_p) if (*work_p)
{ {
linestart = work_p - 1 - cc.Len(); linestart = work_p - 1 - cc.Len();
if (linestart < work)
{
// The line start is outside the buffer.
// Make space for the newly inserted stuff.
size_t movesize = work-linestart;
memmove(work + movesize, work, strlen(work));
work_p += movesize;
linestart = work;
}
linestart[0] = TEXTCOLOR_ESCAPE; linestart[0] = TEXTCOLOR_ESCAPE;
strncpy (linestart + 1, cc, cc.Len()); strncpy (linestart + 1, cc, cc.Len());
} }

View file

@ -80,8 +80,9 @@ public:
virtual void TweakSpeeds (int &forwardmove, int &sidemove); virtual void TweakSpeeds (int &forwardmove, int &sidemove);
virtual void MorphPlayerThink (); virtual void MorphPlayerThink ();
virtual void ActivateMorphWeapon (); virtual void ActivateMorphWeapon ();
virtual AWeapon *PickNewWeapon (const PClass *ammotype); AWeapon *PickNewWeapon (const PClass *ammotype);
virtual AWeapon *BestWeapon (const PClass *ammotype); AWeapon *BestWeapon (const PClass *ammotype);
void CheckWeaponSwitch(const PClass *ammotype);
virtual void GiveDeathmatchInventory (); virtual void GiveDeathmatchInventory ();
virtual void FilterCoopRespawnInventory (APlayerPawn *oldplayer); virtual void FilterCoopRespawnInventory (APlayerPawn *oldplayer);

View file

@ -96,18 +96,9 @@ bool AAmmo::HandlePickup (AInventory *item)
assert (Owner != NULL); assert (Owner != NULL);
if (oldamount == 0 && Owner != NULL && Owner->player != NULL && if (oldamount == 0 && Owner != NULL && Owner->player != NULL)
!Owner->player->userinfo.neverswitch &&
Owner->player->PendingWeapon == WP_NOCHANGE &&
(Owner->player->ReadyWeapon == NULL ||
(Owner->player->ReadyWeapon->WeaponFlags & WIF_WIMPY_WEAPON)))
{ {
AWeapon *best = barrier_cast<APlayerPawn *>(Owner)->BestWeapon (GetClass()); barrier_cast<APlayerPawn *>(Owner)->CheckWeaponSwitch(GetClass());
if (best != NULL && (Owner->player->ReadyWeapon == NULL ||
best->SelectionOrder < Owner->player->ReadyWeapon->SelectionOrder))
{
Owner->player->PendingWeapon = best;
}
} }
} }
return true; return true;

View file

@ -158,8 +158,17 @@ bool AWeapon::PickupForAmmo (AWeapon *ownedWeapon)
// Don't take ammo if the weapon sticks around. // Don't take ammo if the weapon sticks around.
if (!ShouldStay ()) if (!ShouldStay ())
{ {
int oldamount = 0;
if (ownedWeapon->Ammo1 != NULL) oldamount = ownedWeapon->Ammo1->Amount;
if (AmmoGive1 > 0) gotstuff = AddExistingAmmo (ownedWeapon->Ammo1, AmmoGive1); if (AmmoGive1 > 0) gotstuff = AddExistingAmmo (ownedWeapon->Ammo1, AmmoGive1);
if (AmmoGive2 > 0) gotstuff |= AddExistingAmmo (ownedWeapon->Ammo2, AmmoGive2); if (AmmoGive2 > 0) gotstuff |= AddExistingAmmo (ownedWeapon->Ammo2, AmmoGive2);
AActor *Owner = ownedWeapon->Owner;
if (gotstuff && oldamount == 0 && Owner != NULL && Owner->player != NULL)
{
static_cast<APlayerPawn *>(Owner)->CheckWeaponSwitch(ownedWeapon->Ammo1->GetClass());
}
} }
return gotstuff; return gotstuff;
} }

View file

@ -267,6 +267,8 @@ static FSaveGameNode NewSaveNode;
static int epi; // Selected episode static int epi; // Selected episode
static const char *saved_playerclass = NULL;
// PRIVATE MENU DEFINITIONS ------------------------------------------------ // PRIVATE MENU DEFINITIONS ------------------------------------------------
// //
@ -1821,15 +1823,18 @@ void M_Episode (int choice)
if (AllSkills.Size() == 1) if (AllSkills.Size() == 1)
{ {
saved_playerclass = NULL;
M_ChooseSkill(0); M_ChooseSkill(0);
return; return;
} }
else if (EpisodeNoSkill[choice]) else if (EpisodeNoSkill[choice])
{ {
saved_playerclass = NULL;
M_ChooseSkill(AllSkills.Size() == 2? 1:2); M_ChooseSkill(AllSkills.Size() == 2? 1:2);
return; return;
} }
M_StartupSkillMenu(NULL); M_StartupSkillMenu(saved_playerclass);
saved_playerclass = NULL;
} }
//========================================================================== //==========================================================================
@ -1856,6 +1861,7 @@ static void SCClass (int option)
if (EpiDef.numitems > 1) if (EpiDef.numitems > 1)
{ {
saved_playerclass = playerclass;
M_SetupNextMenu (&EpiDef); M_SetupNextMenu (&EpiDef);
} }
else if (AllSkills.Size() == 1) else if (AllSkills.Size() == 1)
@ -1888,6 +1894,7 @@ static void M_ChooseClass (int choice)
if (EpiDef.numitems > 1) if (EpiDef.numitems > 1)
{ {
saved_playerclass = playerclass;
M_SetupNextMenu (&EpiDef); M_SetupNextMenu (&EpiDef);
} }
else if (AllSkills.Size() == 1) else if (AllSkills.Size() == 1)

View file

@ -680,6 +680,31 @@ AWeapon *APlayerPawn::PickNewWeapon (const PClass *ammotype)
return best; return best;
} }
//===========================================================================
//
// APlayerPawn :: CheckWeaponSwitch
//
// Checks if weapons should be changed after picking up ammo
//
//===========================================================================
void APlayerPawn::CheckWeaponSwitch(const PClass *ammotype)
{
if (!player->userinfo.neverswitch &&
player->PendingWeapon == WP_NOCHANGE &&
(player->ReadyWeapon == NULL ||
(player->ReadyWeapon->WeaponFlags & WIF_WIMPY_WEAPON)))
{
AWeapon *best = BestWeapon (ammotype);
if (best != NULL && (player->ReadyWeapon == NULL ||
best->SelectionOrder < player->ReadyWeapon->SelectionOrder))
{
player->PendingWeapon = best;
}
}
}
//=========================================================================== //===========================================================================
// //
// APlayerPawn :: GiveDeathmatchInventory // APlayerPawn :: GiveDeathmatchInventory

View file

@ -325,7 +325,14 @@ do_stop:
sc.ScriptError("Negative jump offsets are not allowed"); sc.ScriptError("Negative jump offsets are not allowed");
} }
x = new FxStateByIndex(bag.statedef.GetStateCount() + v, sc); if (x > 0)
{
x = new FxStateByIndex(bag.statedef.GetStateCount() + v, sc);
}
else
{
x = new FxConstant((FState*)NULL, sc);
}
} }
else else
{ {