Skip to content

Commit

Permalink
Merge pull request #561 from royfalk/sep_21_more_unit
Browse files Browse the repository at this point in the history
Minor refactoring of weapons (beam/bolt)
  • Loading branch information
royfalk authored Sep 27, 2021
2 parents 1333d6b + 6e5e61c commit 5e54110
Show file tree
Hide file tree
Showing 18 changed files with 775 additions and 753 deletions.
1 change: 0 additions & 1 deletion engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,6 @@ ENDIF()

SET(LIBCMD_SOURCES
src/cmd/alphacurve.cpp
src/cmd/beam_generic.cpp
src/cmd/cargo.cpp
src/cmd/carrier.cpp
src/cmd/collection.cpp
Expand Down
2 changes: 1 addition & 1 deletion engine/src/cmd/armed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ Armed::Armed()


///cycles through the loop twice turning on all matching to ms weapons of size or after size
void Armed::ActivateGuns( const weapon_info *sz, bool ms )
void Armed::ActivateGuns( const WeaponInfo *sz, bool ms )
{
for (int j = 0; j < 2; ++j)
for (int i = 0; i < getNumMounts(); ++i)
Expand Down
4 changes: 2 additions & 2 deletions engine/src/cmd/armed.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include "mount.h"
#include <vector>

class weapon_info;
class WeaponInfo;
class Unit;

class Armed
Expand All @@ -46,7 +46,7 @@ class Armed

protected:
//Activates all guns of that size
void ActivateGuns( const weapon_info*, bool Missile );
void ActivateGuns( const WeaponInfo*, bool Missile );

public:
Armed();
Expand Down
4 changes: 2 additions & 2 deletions engine/src/cmd/basecomputer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5535,7 +5535,7 @@ void showUnitStats( Unit *playerUnit, string &text, int subunitlevel, int mode,
PRETTY_ADD( " #c0:1:.3#[#-c", i+1, 0 );
text += "#c0:1:.3#]#-c #c0:1:1#"+getMountSizeString( playerUnit->mounts[i].size )+"#-c";
}
const weapon_info *wi = playerUnit->mounts[i].type;
const WeaponInfo *wi = playerUnit->mounts[i].type;
if (wi && wi->name != "")
anyweapons = true;
}
Expand All @@ -5545,7 +5545,7 @@ void showUnitStats( Unit *playerUnit, string &text, int subunitlevel, int mode,
{
if (anyweapons) {
for (int i = 0; i < playerUnit->getNumMounts(); i++) {
const weapon_info *wi = playerUnit->mounts[i].type;
const WeaponInfo *wi = playerUnit->mounts[i].type;
if ( (!wi) || (wi->name == "") ) {
continue;
} else {
Expand Down
687 changes: 682 additions & 5 deletions engine/src/cmd/beam.cpp

Large diffs are not rendered by default.

55 changes: 29 additions & 26 deletions engine/src/cmd/beam.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ using std::vector;
class Beam
{
private:
const WeaponInfo* type;

int sound;
Transformation local_transformation;
unsigned int decal;
Expand Down Expand Up @@ -78,21 +80,32 @@ class Beam
void RecalculateVertices( const Matrix &trans );
void CollideHuge( const LineCollide&, Unit *targetToCollideWith, Unit *firer, Unit *superunit );
public:
void ListenToOwner( bool listen )
{
listen_to_owner = listen;
}
Beam( const Transformation &trans, const weapon_info &clne, void *own, Unit *firer, int sound );
void Init( const Transformation &trans, const weapon_info &clne, void *own, Unit *firer );
Beam( const Transformation &trans, const WeaponInfo &clne, void *own, Unit *firer, int sound );
void Init( const Transformation &trans, const WeaponInfo &clne, void *own, Unit *firer );
~Beam();
void RemoveFromSystem( bool eradicate );

void Reinitialize();

bool Collide( class Unit*target, Unit*firer, Unit*superunit /*for cargo*/ );

void Destabilize();
bool Dissolved();
void Draw( const Transformation &, const Matrix &, class Unit*target, float trackingcone );

QVector GetPosition() const;

void ListenToOwner( bool listen );

static void ProcessDrawQueue();

bool Ready();
float refireTime();
QVector GetPosition() const
{
return local_transformation.position;
}
void RemoveFromSystem( bool eradicate );


void SetPosition( const QVector& );
void SetOrientation( const Vector &p, const Vector &q, const Vector &r );

void UpdatePhysics( const Transformation &,
const Matrix &,
class Unit*target,
Expand All @@ -101,21 +114,11 @@ class Beam
float HeatSink,
Unit*firer,
Unit*superunit );
void Draw( const Transformation &, const Matrix &, class Unit*target, float trackingcone );
void Destabilize()
{
impact = UNSTABLE;
}
bool Dissolved()
{
return curthick == 0;
}
bool Ready()
{
return curthick == 0 && refiretime > refire;
}
bool Collide( class Unit*target, Unit*firer, Unit*superunit /*for cargo*/ );
static void ProcessDrawQueue();





};
#endif

Loading

0 comments on commit 5e54110

Please sign in to comment.