Skip to content

Commit

Permalink
fix whirpool speed and other cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
stalkerg committed Jun 30, 2024
1 parent 5d1369d commit eb3557c
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 82 deletions.
147 changes: 77 additions & 70 deletions src/units/effect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -585,18 +585,18 @@ void ParticleObject::Quant(void)
else
Visibility = UNVISIBLE;
}
if(Time++ >= LifeTime) Status |= SOBJ_DISCONNECT;
if(Time++ >= LifeTime * GAME_TIME_COEFF) Status |= SOBJ_DISCONNECT;
};

void SimpleParticleType::Quant(void)
{
vR.x += (int)round(vD.x / GAME_TIME_COEFF);
vR.y += (int)round(vD.y / GAME_TIME_COEFF);
vR.z += (int)round(vD.z / GAME_TIME_COEFF);
vR.x += (int)round(vD.x * XTCORE_FRAME_NORMAL);
vR.y += (int)round(vD.y * XTCORE_FRAME_NORMAL);
vR.z += (int)round(vD.z * XTCORE_FRAME_NORMAL);

vR.x &= (int)round(PTrack_mask_x);
vR.y &= (int)round(PTrack_mask_y);
Color += dColor;
vR.x &= (int)round(PTrack_mask_x);
vR.y &= (int)round(PTrack_mask_y);
Color += (int)round(dColor * XTCORE_FRAME_NORMAL);
};

const int PARTICLE_MAX_DELTA = 15 << 8;
Expand Down Expand Up @@ -638,7 +638,7 @@ void SimpleParticleType::QuantRingOfLord(Vector v,int s,int c)

vR.x &= PTrack_mask_x;
// vR.y &= PTrack_mask_y;
Color += dColor;
Color += (int)round(dColor * XTCORE_FRAME_NORMAL);
};

//Angry horde animation quant
Expand All @@ -650,18 +650,18 @@ void SimpleParticleType::QuantP(Vector _c, Vector _n, int s,int c)
tx = -(vR.x - _c.x);
ty = -(vR.y - _c.y);

int SPX_100 = (int)round((SPTorXSize - (300<<8))*XTCORE_FRAME_NORMAL);
int SPY_100 = (int)round((SPTorYSize - (300<<8))*XTCORE_FRAME_NORMAL);
int SPX_100 = SPTorXSize - (300<<8);
int SPY_100 = SPTorYSize - (300<<8);

if(tx > (SPX_100))
tx -= (int)round(SPTorXSize*XTCORE_FRAME_NORMAL);
else if((tx) < (-SPX_100))
tx += (int)round(SPTorXSize*XTCORE_FRAME_NORMAL);
if(tx > SPX_100)
tx -= SPTorXSize;
else if(tx < -SPX_100)
tx += SPTorXSize;

if(ty > (SPY_100) )
ty -= (int)round(SPTorYSize*XTCORE_FRAME_NORMAL);
else if((ty) < (-SPY_100))
ty += (int)round(SPTorYSize*XTCORE_FRAME_NORMAL);
if(ty > SPY_100)
ty -= SPTorYSize;
else if(ty < -SPY_100)
ty += SPTorYSize;

/*px = ty*c;
py = -tx*c;
Expand Down Expand Up @@ -692,7 +692,7 @@ void SimpleParticleType::QuantP(Vector _c, Vector _n, int s,int c)
vD.y += ty * s / d;
vD.z += (_n.z - _c.z) * s / d;
};*/
vR += vD;
vR += vD * XTCORE_FRAME_NORMAL;

vR.x &= PTrack_mask_x;
vR.y &= PTrack_mask_y;
Expand All @@ -708,41 +708,45 @@ void SimpleParticleType::QuantT(int x,int y,int s)
int d;
vTrack.x = x - vR.x;
vTrack.y = y - vR.y;
int SPX_100 = SPTorXSize - (100<<8);
int SPY_100 = SPTorYSize - (100<<8);
int SPX_100 = SPTorXSize - (100 << 8);
int SPY_100 = SPTorYSize - (100 << 8);

if(vTrack.x > (SPX_100) )
if(vTrack.x > SPX_100)
vTrack.x -= SPTorXSize;
else if((vTrack.x) < (-SPX_100))
vTrack.x += SPTorXSize;
else if(vTrack.x < -SPX_100)
vTrack.x += SPTorXSize;

if(vTrack.y > (SPY_100) )
if(vTrack.y > SPY_100)
vTrack.y -= SPTorYSize;
else if((vTrack.y) < (-SPY_100))
vTrack.y += SPTorYSize;
else if(vTrack.y < -SPY_100)
vTrack.y += SPTorYSize;

vTrackP.x = vTrack.y;
vTrackP.y = -vTrack.x;

vTrack.x += vTrackP.x;
vTrack.y += vTrackP.y;

d = (abs(vTrack.x) + abs(vTrack.y))>>2;
d = (abs(vTrack.x) + abs(vTrack.y)) >> 2;
// d <<= WATER_PARTICLE_DIVISION;
if(d){
if(d) {
vD.x = vTrack.x * s / d;
vD.y = vTrack.y * s / d;
};
vD.x -= vD.x >> 4;
vD.y -= vD.y >> 4;
} else {
vD.x -= (vD.x >> 4) * XTCORE_FRAME_NORMAL;
vD.y -= (vD.y >> 4) * XTCORE_FRAME_NORMAL;
}

// d = abs(vD.x) + abs(vD.y);
vD.x -= vD.x >> 4;
vD.y -= vD.y >> 4;


vR += vD;
// vR += vTrack;
vR += vD * XTCORE_FRAME_NORMAL;
// vR += vTrack;
vR.x &= PTrack_mask_x;
vR.y &= PTrack_mask_y;
Color += dColor;
Color += (int)round(dColor * XTCORE_FRAME_NORMAL);
};

void ParticleObject::DrawQuant(void)
Expand All @@ -754,8 +758,8 @@ void ParticleObject::DrawQuant(void)
int phi,dphi;

if(Mode){
if(Time < LifeTime){
dphi = (Time*PI << 8) / (2*NumParticle * LifeTime);
if(Time < LifeTime * GAME_TIME_COEFF){
dphi = (Time*PI << 8) / (2*NumParticle * LifeTime * GAME_TIME_COEFF);
phi = 0;
}else{
phi = PI / 2;
Expand Down Expand Up @@ -897,7 +901,7 @@ void ParticleObject::CreateParticle(ParticleInitDataType* n,const Vector& v1,con

Time = 0;

LifeTime = (int)round(n->LifeTime * GAME_TIME_COEFF);
LifeTime = n->LifeTime;

FirstColor = n->FirstColor << 8;
DeltaColor = ((n->EndColor << 8) - FirstColor) / LifeTime;
Expand Down Expand Up @@ -949,7 +953,7 @@ void ParticleObject::CreateParticle(ParticleInitDataType* n,const Vector& v1,con
Time = 0;
Mode = 0;

LifeTime = (int)round(n->LifeTime * GAME_TIME_COEFF);
LifeTime = n->LifeTime;

FirstColor = n->FirstColor << 8;
DeltaColor = ((n->EndColor << 8) - FirstColor) / LifeTime;
Expand Down Expand Up @@ -1002,7 +1006,7 @@ void ParticleObject::CreateParticle(int _LifeTime,int _Velocity,int _FirstRadius
Time = 0;
Mode = 0;

LifeTime = (int)round(_LifeTime * GAME_TIME_COEFF);
LifeTime = _LifeTime;

FirstColor = _FirstColor << 8;
DeltaColor = ((_EndColor << 8) - FirstColor) / LifeTime;
Expand Down Expand Up @@ -1053,7 +1057,7 @@ void ParticleObject::CreateParticle(int _LifeTime,int _Velocity,int _FirstRadius
Time = 0;
Mode = 0;

LifeTime = (int)round(_LifeTime * GAME_TIME_COEFF);
LifeTime = _LifeTime;

FirstColor = _FirstColor << 8;
DeltaColor = ((_EndColor << 8) - FirstColor) / LifeTime;
Expand Down Expand Up @@ -1103,7 +1107,7 @@ void ParticleObject::CreateParticle(ParticleInitDataType* n,const Vector& v)
int Alpha,StepAlpha;

Time = 0;
LifeTime = (int)round(n->LifeTime * GAME_TIME_COEFF);
LifeTime = n->LifeTime;

Mode = 0;

Expand Down Expand Up @@ -1181,7 +1185,7 @@ void ParticleObject::CreateDirectParticle(ParticleInitDataType* n,const Vector&
Mode = 0;

Time = 0;
LifeTime = (int)round(n->LifeTime );
LifeTime = n->LifeTime;

FirstColor = n->FirstColor << 8;
DeltaColor = ((n->EndColor << 8) - FirstColor) / LifeTime;
Expand Down Expand Up @@ -1247,14 +1251,15 @@ void TargetParticleObject::Quant(void)
};
if(TargetType){
if(Time == 0){
FadeTime = LifeTime - (TARGET_PARTICLE_FADE_TIME * GAME_TIME_COEFF);
FadeNum = CurrParticle / (TARGET_PARTICLE_FADE_TIME * GAME_TIME_COEFF);
FadeTime = LifeTime - TARGET_PARTICLE_FADE_TIME;
FadeNum = CurrParticle / TARGET_PARTICLE_FADE_TIME;
}else{
if(Time >= FadeTime)
CurrParticle -= FadeNum;
if(Time >= FadeTime * GAME_TIME_COEFF)
CurrParticle -= (int)round(FadeNum * XTCORE_FRAME_NORMAL);
};
};
if(++Time > LifeTime) Status |= SOBJ_DISCONNECT;
if(++Time > LifeTime * GAME_TIME_COEFF)
Status |= SOBJ_DISCONNECT;
};


Expand Down Expand Up @@ -1350,19 +1355,17 @@ void TargetParticleType::aQuant(void)
ty = ty * s / d;
tx += (ty >> TARGET_PARTICLE_NORMAL_SHIFT);
ty -= (tx >> TARGET_PARTICLE_NORMAL_SHIFT);
tx /= GAME_TIME_COEFF;
ty /= GAME_TIME_COEFF;
vD.x += tx;
vD.y += ty;
vD.x += (int)round(tx * XTCORE_FRAME_NORMAL);
vD.y += (int)round(ty * XTCORE_FRAME_NORMAL);

if(pDist < d){
vD.x -= vD.x >> 4;
vD.y -= vD.y >> 4;
};

vR.x += vD.x;
vR.y += vD.y;
vR.z += vD.z;
vR.x += (int)round(vD.x * XTCORE_FRAME_NORMAL);
vR.y += (int)round(vD.y * XTCORE_FRAME_NORMAL);
vR.z += (int)round(vD.z * XTCORE_FRAME_NORMAL);

vR.x &= PTrack_mask_x;
// vR.y &= PTrack_mask_y;
Expand All @@ -1382,7 +1385,7 @@ void TargetParticleObject::CreateParticle(const Vector& _vTarget,int _LifeTime,c
{
Time = 0;
CurrParticle = 0;
LifeTime = (int)round(_LifeTime * GAME_TIME_COEFF);
LifeTime = _LifeTime;
R_curr = _vTarget;
cycleTor(R_curr.x,R_curr.y);
vTarget.x = R_curr.x << 8;
Expand Down Expand Up @@ -1425,15 +1428,15 @@ void TargetParticleObject::AddVertex(const Vector& _vR,int _Color,int _Speed1,in

d = vCheck.vabs();
if(d){
vCheck.x = (int)round(_Speed1) * vCheck.x / d;
vCheck.y = (int)round(_Speed1) * vCheck.y / d;
vCheck.x = _Speed1 * vCheck.x / d;
vCheck.y = _Speed1 * vCheck.y / d;
p->vD.x = vCheck.x + vCheck.y;
p->vD.y = vCheck.y - vCheck.x;
}else p->vD = Vector(0,0,0);

p->vD.z = (vCheck.z << 8) / LifeTime;

p->s = (int)round(_Speed2);
p->s = _Speed2;
p->vT = vTarget;
p->pDist = d;
CurrParticle++;
Expand All @@ -1448,9 +1451,9 @@ void TargetParticleType::aQuant2(void)
tx = SPGetDistX(vT.x,vR.x);
ty = vT.y - vR.y;

vR.x += tx / pDist;
vR.y += ty / pDist;
vR.z += s;
vR.x += (int)round((tx / pDist) * XTCORE_FRAME_NORMAL);
vR.y += (int)round((ty / pDist) * XTCORE_FRAME_NORMAL);
vR.z += (int)round(s * XTCORE_FRAME_NORMAL);

vR.x &= PTrack_mask_x;
// vR.y &= PTrack_mask_y;
Expand All @@ -1470,7 +1473,7 @@ void TargetParticleType::aQuant2(void)
}

if(tx > UcutLeft && tx < UcutRight && ty > VcutUp && ty < VcutDown) XGR_SetPixelFast(tx,ty,Color);
};
};

void TargetParticleObject::AddVertex2(const Vector& _vR,const Vector& _vT, int _Color, int _type)
{
Expand All @@ -1491,7 +1494,7 @@ void TargetParticleObject::AddVertex2(const Vector& _vR,const Vector& _vT, int _

p->Color = _Color;
p->type = _type;
p->LifeTime = (int)round(LifeTime );
p->LifeTime = LifeTime;

if (_type){
p->vT.x = vCheck.x << 8;
Expand Down Expand Up @@ -1571,7 +1574,7 @@ void WaterParticleObject::Quant(void)
};
};
// if(z >= (1 << TOUCH_SHIFT)) VsFlag = oUNVISIBLE;
if(Time > LifeTime) Status |= SOBJ_DISCONNECT;
if(Time > LifeTime * GAME_TIME_COEFF) Status |= SOBJ_DISCONNECT;
Time++;
};

Expand All @@ -1583,7 +1586,7 @@ void WaterParticleObject::DrawQuant(void)
int tx,ty;

if(TargetType){
if(Time == SetLifeTime){
if(Time == SetLifeTime * GAME_TIME_COEFF){
if(AdvancedView){
for(i = 0,p = Data;i < NumParticle;i++,p++){
p->QuantT(vCenter.x,vCenter.y,Velocity);
Expand Down Expand Up @@ -1634,7 +1637,7 @@ void WaterParticleObject::DrawQuant(void)
};
};
}else{
if(Time == SetLifeTime){
if(Time == SetLifeTime * GAME_TIME_COEFF){
if(AdvancedView){
for(i = 0,p = Data;i < NumParticle;i++,p++){
p->Quant();
Expand Down Expand Up @@ -1697,8 +1700,8 @@ void WaterParticleObject::CreateParticle(int _LifeTime,int _SetLifeTime,int _Vel

Time = 0;

LifeTime = (int)round(_LifeTime * GAME_TIME_COEFF);
SetLifeTime = (int)round(_SetLifeTime * GAME_TIME_COEFF);
LifeTime = _LifeTime;
SetLifeTime = _SetLifeTime;

FirstColor = _FirstColor << 8;
SetColor = _SetColor << 8;
Expand Down Expand Up @@ -1741,7 +1744,11 @@ void WaterParticleObject::CreateParticle(int _LifeTime,int _SetLifeTime,int _Vel
Radius = RND(radius8);
//Radius = radius8 - RND(10);
p->vR = vCenter + Vector(round(Cos(phi)*Radius),round(Sin(phi)*Radius),0);
p->vD = Vector(_Velocity - effectRND(SignVelocity),_Velocity - effectRND(SignVelocity),_Velocity - effectRND(SignVelocity));
p->vD = Vector(
_Velocity - effectRND(SignVelocity),
_Velocity - effectRND(SignVelocity),
_Velocity - effectRND(SignVelocity)
);
};
};

Expand Down
2 changes: 1 addition & 1 deletion src/units/effect.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ struct SimpleParticleType

struct ParticleInitDataType
{
int LifeTime;
int LifeTime;
int Velocity;
int FirstRadius,EndRadius;
int FirstColor,EndColor;
Expand Down
3 changes: 1 addition & 2 deletions src/units/mechos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2516,7 +2516,6 @@ void ActionDispatcher::Quant(void)
RaceTxtBuff <= n_position < "|" <= n_total;
};

//std::cout<<"age_of_current_game: "<<age_of_current_game()<<" Van_War.MaxTime:"<<my_server_data.Van_War.MaxTime*60<<std::endl;
if(age_of_current_game() >= my_server_data.Van_War.MaxTime*60 || drop_log){
GameOverID = GAME_OVER_NETWORK;
ActD.Active->Status |= SOBJ_DISCONNECT;
Expand Down Expand Up @@ -3571,7 +3570,7 @@ void VangerUnit::DrawQuant(void)
int i;

if(!ExternalDraw || (Status & SOBJ_WAIT_CONFIRMATION)) return;
TrackUnit::DrawQuant();
TrackUnit::DrawQuant();
Vector vCheck;

if(ExternalMode == EXTERNAL_MODE_NORMAL){
Expand Down
Loading

0 comments on commit eb3557c

Please sign in to comment.