Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
royfalk committed Nov 25, 2024
2 parents 4f72ce2 + a7c8bb7 commit a86672e
Show file tree
Hide file tree
Showing 50 changed files with 1,836 additions and 861 deletions.
7 changes: 7 additions & 0 deletions engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -727,13 +727,18 @@ SET(LIBPYTHON

SET(LIBCOMPONENT
src/components/component.cpp
src/components/dummy_component.cpp
src/components/component_utils

src/components/energy_consumer.cpp
src/components/energy_container.cpp
src/components/reactor.cpp

src/components/afterburner.cpp
src/components/afterburner_upgrade.cpp
src/components/cloak.cpp
src/components/drive.cpp
src/components/drive_upgrade.cpp
src/components/ftl_drive.cpp
src/components/jump_drive.cpp
)
Expand Down Expand Up @@ -1753,6 +1758,8 @@ IF (USE_GTEST)
src/exit_unit_tests.cpp
src/components/tests/energy_container_tests.cpp
src/components/tests/balancing_tests.cpp
src/components/tests/drive_tests.cpp
src/components/tests/afterburner_tests.cpp
src/components/tests/jump_drive_tests.cpp
)

Expand Down
4 changes: 2 additions & 2 deletions engine/objconv/basemaker/base_maker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2166,8 +2166,8 @@ int main(int argc, char **argv) {
Base::CurrentBase = NULL;
glutInit(&argc, argv);
glutInitWindowSize(800, 600);
g_game.x_resolution = 800;
g_game.y_resolution = 600;
g_game.x_resolution = 1920;
g_game.y_resolution = 1080;
glutInitWindowPosition(0, 0);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
glutCreateWindow("Vega Strike Base Maker");
Expand Down
10 changes: 5 additions & 5 deletions engine/src/cmd/ai/aggressive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ bool AggressiveAI::ExecuteLogicItem(const AIEvents::AIEvresult &item) {
}

bool AggressiveAI::ProcessLogicItem(const AIEvents::AIEvresult &item) {
float value = 0.0;
double value = 0.0;

switch (abs(item.type)) {
case DISTANCE:
Expand All @@ -317,11 +317,11 @@ bool AggressiveAI::ProcessLogicItem(const AIEvents::AIEvresult &item) {
Unit *targ = parent->Target();
if (targ) {
Vector PosDifference = targ->Position().Cast() - parent->Position().Cast();
float pdmag = PosDifference.Magnitude();
double pdmag = PosDifference.Magnitude();
value = (pdmag - parent->rSize() - targ->rSize());
float myvel = PosDifference.Dot(parent->GetVelocity() - targ->GetVelocity()) / value; ///pdmag;
double myvel = PosDifference.Dot(parent->GetVelocity() - targ->GetVelocity()) / value; ///pdmag;
if (myvel > 0) {
value -= myvel * myvel / (2 * (parent->limits.retro / parent->getMass()));
value -= myvel * myvel / (2 * (parent->drive.retro / parent->getMass()));
}
} else {
value = 10000;
Expand Down Expand Up @@ -1727,7 +1727,7 @@ void AggressiveAI::Execute() {
mag = 1 / mag;
}
parent->SetVelocity(
parent->GetVelocity() * (mag * parent->GetComputerData().max_speed() / getTimeCompression()));
parent->GetVelocity() * (mag * parent->MaxSpeed() / getTimeCompression()));
parent->NetLocalForce = parent->NetForce = Vector(0, 0, 0);
}
target = parent->Target();
Expand Down
4 changes: 2 additions & 2 deletions engine/src/cmd/ai/fire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@ bool FireAt::PursueTarget(Unit *un, bool leader) {
bool CanFaceTarget(Unit *su, Unit *targ, const Matrix &matrix) {
return true;

float limitmin = su->limits.limitmin;
float limitmin = su->limit_min;
if (limitmin > -.99) {
QVector pos = (targ->Position() - su->Position()).Normalize();
QVector pnorm = pos.Cast();
Vector structurelimits = su->limits.structurelimits;
Vector structurelimits = su->structure_limits;
Vector worldlimit = TransformNormal(matrix, structurelimits);
if (pnorm.Dot(worldlimit) < limitmin) {
return false;
Expand Down
48 changes: 24 additions & 24 deletions engine/src/cmd/ai/flybywire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,16 +192,16 @@ FlyByWire::FlyByWire() : MatchVelocity(Vector(0, 0, 0), Vector(0, 0, 0), true, f
}

void FlyByWire::Stop(float per) {
SetDesiredVelocity(Vector(0, 0, per * parent->GetComputerData().max_speed()), true);
SetDesiredVelocity(Vector(0, 0, per * parent->MaxSpeed()), true);

parent->GetComputerData().set_speed = per * parent->GetComputerData().max_speed();
parent->GetComputerData().set_speed = per * parent->MaxSpeed();
}

void FlyByWire::Right(float per) {
desired_ang_velocity +=
(-per
* (per
> 0 ? parent->GetComputerData().max_yaw_left : parent->GetComputerData().max_yaw_right)
> 0 ? parent->drive.max_yaw_left : parent->drive.max_yaw_right)
/ getTimeCompression()) * Vector(
0,
1,
Expand All @@ -212,7 +212,7 @@ void FlyByWire::Up(float per) {
desired_ang_velocity +=
(-per
* (per
> 0 ? parent->GetComputerData().max_pitch_down : parent->GetComputerData().max_pitch_up)
> 0 ? parent->drive.max_pitch_down : parent->drive.max_pitch_up)
/ getTimeCompression()) * Vector(
1,
0,
Expand All @@ -223,7 +223,7 @@ void FlyByWire::RollRight(float per) {
desired_ang_velocity +=
(-per
* (per
> 0 ? parent->GetComputerData().max_roll_left : parent->GetComputerData().max_roll_right)
> 0 ? parent->drive.max_roll_left : parent->drive.max_roll_right)
/ getTimeCompression()) * Vector(
0,
0,
Expand All @@ -235,9 +235,9 @@ void FlyByWire::Afterburn(float per) {

afterburn = (per > .1);
if (!sheltonslide && !inertial_flight_model) {
desired_velocity = Vector(0, 0, cpu->set_speed + per * (cpu->max_ab_speed() - cpu->set_speed));
desired_velocity = Vector(0, 0, cpu->set_speed + per * (parent->MaxAfterburnerSpeed() - cpu->set_speed));
} else if (inertial_flight_model) {
DirectThrust += Vector(0, 0, parent->limits.afterburn * per);
DirectThrust += Vector(0, 0, parent->afterburner.thrust * per);
}
if (parent == _Universe->AccessCockpit()->GetParent()) {
//printf("afterburn is %d\n",afterburn); // DELETEME WTF all this force feedback code and its unused.
Expand All @@ -254,22 +254,22 @@ void FlyByWire::MatchSpeed(const Vector &vec) {
Computer *cpu = &parent->GetComputerData();

cpu->set_speed = (vec).Magnitude();
if (cpu->set_speed > cpu->max_speed()) {
cpu->set_speed = cpu->max_speed();
if (cpu->set_speed > parent->MaxSpeed()) {
cpu->set_speed = parent->MaxSpeed();
}
}

void FlyByWire::Accel(float per) {
Computer *cpu = &parent->GetComputerData();

cpu->set_speed += per * cpu->max_speed() * simulation_atom_var; //SIMULATION_ATOM?
if (cpu->set_speed > cpu->max_speed()) {
cpu->set_speed = cpu->max_speed();
cpu->set_speed += per * parent->MaxSpeed() * simulation_atom_var; //SIMULATION_ATOM?
if (cpu->set_speed > parent->MaxSpeed()) {
cpu->set_speed = parent->MaxSpeed();
}
static float reverse_speed_limit =
XMLSupport::parse_float(vs_config->getVariable("physics", "reverse_speed_limit", "1.0"));
if (cpu->set_speed < -cpu->max_speed() * reverse_speed_limit) {
cpu->set_speed = -cpu->max_speed() * reverse_speed_limit;
if (cpu->set_speed < -parent->MaxSpeed() * reverse_speed_limit) {
cpu->set_speed = -parent->MaxSpeed() * reverse_speed_limit;
}
afterburn = false;

Expand All @@ -279,30 +279,30 @@ void FlyByWire::Accel(float per) {
#define FBWABS(m) (m >= 0 ? m : -m)

void FlyByWire::ThrustRight(float percent) {
DesiredShiftVelocity.i = parent->GetComputerData().max_speed() * percent;
DesiredShiftVelocity.i = parent->MaxSpeed() * percent;
}

void FlyByWire::ThrustUp(float percent) {
DesiredShiftVelocity.j = parent->GetComputerData().max_speed() * percent;
DesiredShiftVelocity.j = parent->MaxSpeed() * percent;
}

void FlyByWire::ThrustFront(float percent) {
DesiredShiftVelocity.k = parent->GetComputerData().max_speed() * percent;
DesiredShiftVelocity.k = parent->MaxSpeed() * percent;
}

void FlyByWire::DirectThrustRight(float percent) {
DirectThrust.i = parent->limits.lateral * percent;
DirectThrust.i = parent->drive.lateral * percent;
}

void FlyByWire::DirectThrustUp(float percent) {
DirectThrust.j = parent->limits.vertical * percent;
DirectThrust.j = parent->drive.vertical * percent;
}

void FlyByWire::DirectThrustFront(float percent) {
if (percent > 0) {
DirectThrust.k = parent->limits.forward * percent;
DirectThrust.k = parent->drive.forward * percent;
} else {
DirectThrust.k = parent->limits.retro * percent;
DirectThrust.k = parent->drive.retro * percent;
}
}

Expand All @@ -312,8 +312,8 @@ void FlyByWire::Execute() {
if (!inertial_flight_model) {
//Must translate the thrust values to velocities, which is somewhat cumbersome.
Vector Limit(
parent->limits.lateral, parent->limits.vertical,
((DirectThrust.k > 0) ? parent->limits.forward : parent->limits.retro)
parent->drive.lateral, parent->drive.vertical,
((DirectThrust.k > 0) ? parent->drive.forward : parent->drive.retro)
);
if (Limit.i <= 1) {
Limit.i = 1;
Expand All @@ -330,7 +330,7 @@ void FlyByWire::Execute() {
DirectThrust.k / Limit.k
);
//Now, scale so that maximum shift velocity is max_speed
DesiredDrift *= parent->GetComputerData().max_speed();
DesiredDrift *= parent->MaxSpeed();
//And apply
DesiredShiftVelocity += DesiredDrift;
}
Expand Down
2 changes: 1 addition & 1 deletion engine/src/cmd/ai/flyjoystick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ void FlyByJoystick::Execute() {
float(expamountc * (exp(expfactorc * axis_value) - 1) / norm
+ pamountc * pow(axis_value, pfactorc));
}
cpu->set_speed = axis_value * cpu->max_speed();
cpu->set_speed = axis_value * parent->MaxSpeed();
desired_velocity = Vector(0, 0, cpu->set_speed);
}
}
Expand Down
28 changes: 13 additions & 15 deletions engine/src/cmd/ai/hard_coded_scripts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ void BarrelRoll(Order *aisc, Unit *un) {
bool afterburn = useAfterburner();
broll->MatchSpeed(Vector(0,
0,
afterburn ? un->GetComputerData().max_ab_speed() : un->GetComputerData().max_speed()));
afterburn ? un->MaxAfterburnerSpeed() : un->MaxSpeed()));
broll->Afterburn(afterburn);
}

Expand All @@ -246,7 +246,7 @@ static void EvadeWavy(Order *aisc, Unit *un, bool updown, bool ab) {
bool afterburn = ab && useAfterburner();
broll->MatchSpeed(Vector(0,
0,
afterburn ? un->GetComputerData().max_ab_speed() : un->GetComputerData().max_speed()));
afterburn ? un->MaxAfterburnerSpeed() : un->MaxSpeed()));
broll->Afterburn(afterburn);
}

Expand Down Expand Up @@ -330,11 +330,10 @@ class LoopAround : public Orders::FaceTargetITTS {
Vector r = targ->cumulative_transformation_matrix.getR();
bool afterburn = useAfterburner() && this->afterburn;
bool ab_needed =
force_afterburn || targ->GetVelocity().MagnitudeSquared() > parent->GetComputerData().max_speed();
force_afterburn || targ->GetVelocity().MagnitudeSquared() > parent->MaxSpeed();
m.SetDesiredVelocity(Vector(0, 0, afterburn
&& ab_needed ? parent->GetComputerData().max_ab_speed()
: parent->GetComputerData().
max_speed()), true);
&& ab_needed ? parent->MaxAfterburnerSpeed()
: parent->MaxSpeed()), true);
float spseed, grange = 0, mrange = 0;
parent->getAverageGunSpeed(spseed, grange, mrange);
if (r.Dot(relloc) < 0) {
Expand Down Expand Up @@ -429,7 +428,7 @@ class LoopAroundAgro : public Orders::FaceTargetITTS {
Vector r = targ->cumulative_transformation_matrix.getR();
bool afterburn = useAfterburner() && this->afterburn;
bool ab_needed =
force_afterburn || targ->GetVelocity().MagnitudeSquared() > parent->GetComputerData().max_speed();
force_afterburn || targ->GetVelocity().MagnitudeSquared() > parent->MaxSpeed();
if (r.Dot(relloc) < 0) {
FaceTargetITTS::Execute();
m.SetAfterburn(afterburn && ab_needed);
Expand Down Expand Up @@ -530,11 +529,10 @@ class FacePerpendicular : public Orders::FaceTargetITTS {
Vector r = targ->cumulative_transformation_matrix.getR();
bool afterburn = useAfterburner() && this->afterburn;
bool ab_needed =
force_afterburn || targ->GetVelocity().MagnitudeSquared() > parent->GetComputerData().max_speed();
force_afterburn || targ->GetVelocity().MagnitudeSquared() > parent->MaxSpeed();
m.SetDesiredVelocity(Vector(0, 0, afterburn
&& ab_needed ? parent->GetComputerData().max_ab_speed()
: parent->GetComputerData().
max_speed()), true);
&& ab_needed ? parent->MaxAfterburnerSpeed()
: parent->MaxSpeed()), true);
float speed, grange = 0, mrange = 0;
parent->getAverageGunSpeed(speed, grange, mrange);
if (r.Dot(relloc) < 0) {
Expand Down Expand Up @@ -585,15 +583,15 @@ void RollLeft(Order *aisc, Unit *un) {
if (un->aistate) {
AddOrd(un->aistate,
un,
new Orders::ExecuteFor(new Orders::MatchRoll(un->GetComputerData().max_roll_right, false), 1.0f));
new Orders::ExecuteFor(new Orders::MatchRoll(un->drive.max_roll_right, false), 1.0f));
}
}

void RollRight(Order *aisc, Unit *un) {
if (un->aistate) {
AddOrd(un->aistate,
un,
new Orders::ExecuteFor(new Orders::MatchRoll(-un->GetComputerData().max_roll_left, false), 1.0f));
new Orders::ExecuteFor(new Orders::MatchRoll(-un->drive.max_roll_left, false), 1.0f));
}
}

Expand All @@ -602,7 +600,7 @@ void RollLeftHard(Order *aisc, Unit *un) {
if (un->aistate) {
AddOrd(un->aistate,
un,
new Orders::ExecuteFor(new Orders::MatchRoll(un->GetComputerData().max_roll_right, false), durvar));
new Orders::ExecuteFor(new Orders::MatchRoll(un->drive.max_roll_right, false), durvar));
}
}

Expand All @@ -611,7 +609,7 @@ void RollRightHard(Order *aisc, Unit *un) {
if (un->aistate) {
AddOrd(un->aistate,
un,
new Orders::ExecuteFor(new Orders::MatchRoll(-un->GetComputerData().max_roll_left, false), durvar));
new Orders::ExecuteFor(new Orders::MatchRoll(-un->drive.max_roll_left, false), durvar));
}
}

Expand Down
Loading

0 comments on commit a86672e

Please sign in to comment.