Skip to content

Commit

Permalink
Fix lassat firing too many times when clicking fast.
Browse files Browse the repository at this point in the history
Fixes ticket:3163.
  • Loading branch information
Cyp committed Feb 13, 2012
1 parent ea37769 commit ea8d833
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 31 deletions.
16 changes: 16 additions & 0 deletions src/multistruct.cpp
Expand Up @@ -49,6 +49,7 @@
#include "research.h"
#include "qtscript.h"
#include "keymap.h"
#include "combat.h"

// ////////////////////////////////////////////////////////////////////////////
// structures
Expand Down Expand Up @@ -239,6 +240,21 @@ bool recvLasSat(NETQUEUE queue)

if (psStruct && psObj && psStruct->pStructureType->psWeapStat[0]->weaponSubClass == WSC_LAS_SAT)
{
// Lassats have just one weapon
unsigned firePause = weaponFirePause(&asWeaponStats[psStruct->asWeaps[0].nStat], player);
unsigned damLevel = PERCENT(psStruct->body, structureBody(psStruct));

if (damLevel < HEAVY_DAMAGE_LEVEL)
{
firePause += firePause;
}

if (isHumanPlayer(player) && gameTime - psStruct->asWeaps[0].lastFired <= firePause)
{
/* Too soon to fire again */
return true ^ false; // Return value meaningless and ignored.
}

// Give enemy no quarter, unleash the lasat
proj_SendProjectile(&psStruct->asWeaps[0], NULL, player, psObj->pos, psObj, true, 0);
psStruct->asWeaps[0].lastFired = gameTime;
Expand Down
32 changes: 1 addition & 31 deletions src/order.cpp
Expand Up @@ -4096,38 +4096,8 @@ void orderStructureObj(UDWORD player, BASE_OBJECT *psObj)
{
if (lasSatStructSelected(psStruct))
{
// Lassats have just one weapon
unsigned int firePause = weaponFirePause(&asWeaponStats[psStruct->asWeaps[0].nStat], (UBYTE)player);
unsigned int damLevel = PERCENT(psStruct->body, structureBody(psStruct));

if (damLevel < HEAVY_DAMAGE_LEVEL)
{
firePause += firePause;
}

if (isHumanPlayer(player)
&& (gameTime - psStruct->asWeaps[0].lastFired <= firePause) )
{
/* Too soon to fire again */
break;
}

// send the weapon fire
if(bMultiMessages)
{
sendLasSat(player,psStruct,psObj);
}
else
{
//ok to fire - so fire away
proj_SendProjectile(&psStruct->asWeaps[0], NULL, player, psObj->pos, psObj, true, 0);
//set up last fires time
psStruct->asWeaps[0].lastFired = gameTime;
psStruct->asWeaps[0].ammo = 1; // see SendLasSat()

//play 5 second countdown message
audio_QueueTrackPos(ID_SOUND_LAS_SAT_COUNTDOWN, psObj->pos.x, psObj->pos.y, psObj->pos.z);
}
sendLasSat(player, psStruct, psObj);

break;
}
Expand Down

0 comments on commit ea8d833

Please sign in to comment.