~swag/armagetronad/0.2.9-sty+ct+ap-fork

« back to all changes in this revision

Viewing changes to src/tron/gCycle.cpp

  • Committer: SwagTron
  • Date: 2019-03-03 20:57:16 UTC
  • Revision ID: swagtron-20190303205716-nk32wtrusb3tum54
As far as I am aware, compiling 2.9 sty+ct+ap was incredibly difficult and impossible without using older versions merged with the latest revision (thanks to Nelg's help). Created a proper win32 folder, a readme file, and made it simple to compile for windows.

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
#include "eDebugLine.h"
51
51
#include "eLagCompensation.h"
52
52
#include "gArena.h"
53
 
#include "gZone.h"
54
 
 
55
 
#include "gRace.h"
56
 
#include "gGame.h"
 
53
#include "gZone.h"
 
54
 
 
55
#include "gRace.h"
 
56
#include "gGame.h"
57
57
 
58
58
#include "tMath.h"
59
59
#include <stdlib.h>
152
152
                               sg_speedCycleSound);
153
153
 
154
154
// time after spawning it takes the cycle to start building a wall
155
 
static REAL sg_cycleWallTime = 0.0;
 
155
static REAL sg_cycleWallTime = 0.0;
156
156
static nSettingItemWatched<REAL> sg_cycleWallTimeConf("CYCLE_WALL_TIME", sg_cycleWallTime, nConfItemVersionWatcher::Group_Bumpy, 12);
157
157
 
158
158
// time after spawning during which a cycle can't be killed
2425
2425
        currentWall(NULL),
2426
2426
        lastWall(NULL)
2427
2427
{
2428
 
/*    
2429
 
    se_cycleCreatedWriter << p->GetLogName() << this->MapPosition().x << this->MapPosition().y << this->MapDirection().x << this->MapDirection().y << (p->CurrentTeam()?Team()->Name().Filter():"") << se_GameTime();
 
2428
    se_cycleCreatedWriter << p->GetLogName() << this->MapPosition().x << this->MapPosition().y << this->MapDirection().x << this->MapDirection().y << Team()->Name().Filter() << se_GameTime();
2430
2429
    se_cycleCreatedWriter.write();
2431
 
*/
 
2430
 
2432
2431
    windingNumberWrapped_ = windingNumber_ = Grid()->DirectionWinding(dirDrive);
2433
2432
    dirDrive = Grid()->GetDirection(windingNumberWrapped_);
2434
2433
    dir = dirDrive;
2444
2443
    sg_ArchiveCoord( this->pos, 1 );
2445
2444
    sg_ArchiveReal( this->verletSpeed_, 1 );
2446
2445
 
2447
 
    flag_ = NULL;
2448
 
 
2449
 
    startPos_ = this->pos;
2450
 
    startDir_ = this->dir;
2451
 
 
2452
 
    tString logTurnsMsg;
2453
 
    logTurnsMsg << "spawned " << this->MapPosition().x << " " << this->MapPosition().y << " " << this->MapDirection().x << " " << this->MapDirection().y;
2454
 
    LogPlayersCycleTurns(this, logTurnsMsg);
2455
 
 
2456
 
    turnedPositions.push_back(startPos_);
 
2446
    flag_ = NULL;
 
2447
 
 
2448
    startPos_ = this->pos;
 
2449
    startDir_ = this->dir;
 
2450
 
 
2451
    tString logTurnsMsg;
 
2452
    logTurnsMsg << "spawned " << this->MapPosition().x << " " << this->MapPosition().y << " " << this->MapDirection().x << " " << this->MapDirection().y;
 
2453
    LogPlayersCycleTurns(this, logTurnsMsg);
 
2454
 
 
2455
    turnedPositions.push_back(startPos_);
2457
2456
    turnedDirections.push_back(startDir_);
2458
2457
}
2459
2458
 
2481
2480
 
2482
2481
    tDESTROY(engine);
2483
2482
    tDESTROY(turning);
2484
 
    tDESTROY(spark);
2485
 
 
2486
 
    turnedPositions.clear();
 
2483
    tDESTROY(spark);
 
2484
 
 
2485
    turnedPositions.clear();
2487
2486
    turnedDirections.clear();
2488
2487
 
2489
2488
    this->RemoveFromGame();
2879
2878
#ifdef DEDICATED
2880
2879
    if ( Alive() && currentTime > lastTime + Lag() + 1 )
2881
2880
    {
2882
 
        //sn_ConsoleOut( "0xff7777Admin : 0xffff77BUG had to kill a cycle because it lagged behind in the simulation. Probably the invulnerability bug. Investigate!\n" );
 
2881
        sn_ConsoleOut( "0xff7777Admin : 0xffff77BUG had to kill a cycle because it lagged behind in the simulation. Probably the invulnerability bug. Investigate!\n" );
2883
2882
        st_Breakpoint();
2884
2883
        KillAt( pos );
2885
2884
        ret = false;
3056
3055
            // delegate core work to base class
3057
3056
            try
3058
3057
            {
3059
 
                // start building wall
 
3058
                // start building wall
3060
3059
                REAL startBuildWallAt = spawnTime_ + sg_cycleWallTime;
3061
3060
                if ( !currentWall && currentTime > startBuildWallAt  )
3062
3061
                {
3072
3071
                    DropWall();
3073
3072
                    spawnTime_ = lastSpawn;
3074
3073
                    lastTurnPos_ = pos; // hack last turn position to generate good wall
3075
 
                }
 
3074
                }
3076
3075
 
3077
3076
                // simulate rest of frame
3078
3077
                if ( gCycleMovement::TimestepCore( currentTime, calculateAcceleration ) )
3735
3734
        return .9f;
3736
3735
    else
3737
3736
        return 1;
3738
 
}
3739
 
 
3740
 
#ifndef DEDICATED
3741
 
static void se_cycleTurn(std::istream &s)
3742
 
{
3743
 
    ePlayerNetID *player = NULL;
3744
 
    player = se_GetLocalPlayer();
3745
 
 
3746
 
    tString times, turn;
3747
 
    s >> times;
3748
 
    s >> turn;
3749
 
 
3750
 
    int x = atoi(times);
3751
 
    if (player)
3752
 
    {
3753
 
        gCycle *cycle = dynamic_cast<gCycle *>(player->Object());
3754
 
        if (cycle && cycle->Alive())
3755
 
        {
3756
 
            if (turn.Filter() == "left")
3757
 
            {
3758
 
                for(int i = 0; i < x; i++)
3759
 
                {
3760
 
                    cycle->Act(&gCycle::se_turnLeft, 1);
3761
 
                }
3762
 
            }
3763
 
            else if (turn.Filter() == "right")
3764
 
            {
3765
 
                for(int i = 0; i < x; i++)
3766
 
                {
3767
 
                    cycle->Act(&gCycle::se_turnRight, 1);
3768
 
                }
3769
 
            }
3770
 
            else
3771
 
            {
3772
 
                tString msg;
3773
 
                msg << "Usage: CYCLE_TURN <times> [turn: left | right] required.\n";
3774
 
                sn_ConsoleOut(msg, player->Owner());
3775
 
            }
3776
 
        }
3777
 
    }
3778
 
}
 
3737
}
 
3738
 
 
3739
#ifndef DEDICATED
 
3740
static void se_cycleTurn(std::istream &s)
 
3741
{
 
3742
    ePlayerNetID *player = NULL;
 
3743
    player = se_GetLocalPlayer();
 
3744
 
 
3745
    tString times, turn;
 
3746
    s >> times;
 
3747
    s >> turn;
 
3748
 
 
3749
    int x = atoi(times);
 
3750
    if (player)
 
3751
    {
 
3752
        gCycle *cycle = dynamic_cast<gCycle *>(player->Object());
 
3753
        if (cycle && cycle->Alive())
 
3754
        {
 
3755
            if (turn.Filter() == "left")
 
3756
            {
 
3757
                for(int i = 0; i < x; i++)
 
3758
                {
 
3759
                    cycle->Act(&gCycle::se_turnLeft, 1);
 
3760
                }
 
3761
            }
 
3762
            else if (turn.Filter() == "right")
 
3763
            {
 
3764
                for(int i = 0; i < x; i++)
 
3765
                {
 
3766
                    cycle->Act(&gCycle::se_turnRight, 1);
 
3767
                }
 
3768
            }
 
3769
            else
 
3770
            {
 
3771
                tString msg;
 
3772
                msg << "Usage: CYCLE_TURN <times> [turn: left | right] required.\n";
 
3773
                sn_ConsoleOut(msg, player->Owner());
 
3774
            }
 
3775
        }
 
3776
    }
 
3777
}
3779
3778
static tConfItemFunc se_cycleTurnConf("CYCLE_TURN", &se_cycleTurn);
3780
3779
#endif
3781
3780
 
3906
3905
                gFakeDirDriveSetter fakeSetter( dirDriveFake );
3907
3906
                DropWall();
3908
3907
                lastDirDrive = lastDirDriveBack;
3909
 
            }
3910
 
 
3911
 
#ifdef DEBUG
3912
 
            REAL thisRadians = atan2f(dirDrive.y, dirDrive.x);
3913
 
            REAL thisDegrees = thisRadians * (180.0 / M_PI);
3914
 
            con << "Turn Angle: " << thisDegrees << " | x: " << dirDrive.x << " y: " << dirDrive.y << "\n\n";
3915
 
#endif
3916
 
 
3917
 
            //  RACE HACK BEGIN
3918
 
            if (sg_RaceTimerEnabled && (sg_RaceSafeAngles != ""))
3919
 
            {
3920
 
                bool racer_safe = false;
3921
 
 
3922
 
                tArray<tString> degreesList = sg_RaceSafeAngles.Split(",");
3923
 
                for(int iD = 0; iD < degreesList.Len(); iD++)
3924
 
                {
3925
 
                    if (degreesList[iD].Filter() == "") continue;
3926
 
 
3927
 
                    //  if this is set, then all angles are safe.
3928
 
                    //  any angle after this is unsafe
3929
 
                    REAL degrees = atof(degreesList[iD]);
3930
 
                    if (degrees == -1)
3931
 
                    {
3932
 
                        racer_safe = true;
3933
 
                        continue;
3934
 
                    }
3935
 
                    REAL radians = degrees * (M_PI / 180.0);
3936
 
                    eCoord radianCoord = eCoord(cos(radians), sin(radians));
3937
 
 
3938
 
                    REAL radX = radianCoord.x;
3939
 
                    REAL radXA = radX * 10.0f;
3940
 
                    REAL radXB = ((int)radXA) / 10.0f;
3941
 
                    radianCoord.x = ((radXB == 0) ? 0 : radX);
3942
 
 
3943
 
                    REAL radY = radianCoord.y;
3944
 
                    REAL radYA = radY * 10.0f;
3945
 
                    REAL radYB = ((int)radYA) / 10.0f;
3946
 
                    radianCoord.y = ((radYB == 0) ? 0 : radY);
3947
 
#ifdef DEBUG
3948
 
                    con << radXB << " " << radYB << "\n";
3949
 
#endif
3950
 
 
3951
 
                    //  check the direction this player is turning into and if its safe, good. if not, lets check again
3952
 
                    if ((radianCoord.x == dirDrive.x) && (radianCoord.y == dirDrive.y))
3953
 
                    {
3954
 
#ifdef DEBUG
3955
 
                        con << "Checked Angle: " << degrees << " | x: " << radianCoord.x << " y: " << radianCoord.y << "\n\n";
3956
 
#endif
3957
 
 
3958
 
                        if (racer_safe)
3959
 
                            racer_safe = false;
3960
 
                        else
3961
 
                            racer_safe = true;
3962
 
                        break;
3963
 
                    }
3964
 
                }
3965
 
 
3966
 
                gRacePlayer *racer = gRacePlayer::GetPlayer(Player());
3967
 
                if (racer)
3968
 
                    racer->SetSafe(racer_safe);
3969
 
            }
3970
 
            //  RACE HACK END
3971
 
 
3972
 
            tString logTurnPos;
3973
 
            logTurnPos << pos.x << " " << pos.y << " " << dirDrive.x << " " << dirDrive.y;
3974
 
            LogPlayersCycleTurns(this, logTurnPos);
3975
 
 
3976
 
            turnedPositions.push_back(pos);
 
3908
            }
 
3909
 
 
3910
#ifdef DEBUG
 
3911
            REAL thisRadians = atan2f(dirDrive.y, dirDrive.x);
 
3912
            REAL thisDegrees = thisRadians * (180.0 / M_PI);
 
3913
            con << "Turn Angle: " << thisDegrees << " | x: " << dirDrive.x << " y: " << dirDrive.y << "\n\n";
 
3914
#endif
 
3915
 
 
3916
            //  RACE HACK BEGIN
 
3917
            if (sg_RaceTimerEnabled && (sg_RaceSafeAngles != ""))
 
3918
            {
 
3919
                bool racer_safe = false;
 
3920
 
 
3921
                tArray<tString> degreesList = sg_RaceSafeAngles.Split(",");
 
3922
                for(int iD = 0; iD < degreesList.Len(); iD++)
 
3923
                {
 
3924
                    if (degreesList[iD].Filter() == "") continue;
 
3925
 
 
3926
                    //  if this is set, then all angles are safe.
 
3927
                    //  any angle after this is unsafe
 
3928
                    REAL degrees = atof(degreesList[iD]);
 
3929
                    if (degrees == -1)
 
3930
                    {
 
3931
                        racer_safe = true;
 
3932
                        continue;
 
3933
                    }
 
3934
                    REAL radians = degrees * (M_PI / 180.0);
 
3935
                    eCoord radianCoord = eCoord(cos(radians), sin(radians));
 
3936
 
 
3937
                    REAL radX = radianCoord.x;
 
3938
                    REAL radXA = radX * 10.0f;
 
3939
                    REAL radXB = ((int)radXA) / 10.0f;
 
3940
                    radianCoord.x = ((radXB == 0) ? 0 : radX);
 
3941
 
 
3942
                    REAL radY = radianCoord.y;
 
3943
                    REAL radYA = radY * 10.0f;
 
3944
                    REAL radYB = ((int)radYA) / 10.0f;
 
3945
                    radianCoord.y = ((radYB == 0) ? 0 : radY);
 
3946
#ifdef DEBUG
 
3947
                    con << radXB << " " << radYB << "\n";
 
3948
#endif
 
3949
 
 
3950
                    //  check the direction this player is turning into and if its safe, good. if not, lets check again
 
3951
                    if ((radianCoord.x == dirDrive.x) && (radianCoord.y == dirDrive.y))
 
3952
                    {
 
3953
#ifdef DEBUG
 
3954
                        con << "Checked Angle: " << degrees << " | x: " << radianCoord.x << " y: " << radianCoord.y << "\n\n";
 
3955
#endif
 
3956
 
 
3957
                        if (racer_safe)
 
3958
                            racer_safe = false;
 
3959
                        else
 
3960
                            racer_safe = true;
 
3961
                        break;
 
3962
                    }
 
3963
                }
 
3964
 
 
3965
                gRacePlayer *racer = gRacePlayer::GetPlayer(Player());
 
3966
                if (racer)
 
3967
                    racer->SetSafe(racer_safe);
 
3968
            }
 
3969
            //  RACE HACK END
 
3970
 
 
3971
            tString logTurnPos;
 
3972
            logTurnPos << pos.x << " " << pos.y << " " << dirDrive.x << " " << dirDrive.y;
 
3973
            LogPlayersCycleTurns(this, logTurnPos);
 
3974
 
 
3975
            turnedPositions.push_back(pos);
3977
3976
            turnedDirections.push_back(dirDrive);
3978
3977
 
3979
3978
            return true;
4000
3999
        currentWall->CopyIntoGrid( grid );
4001
4000
        currentWall=NULL;
4002
4001
    }
4003
 
 
 
4002
 
4004
4003
    if ( buildNew && lastTime >= spawnTime_ + sg_cycleWallTime )
4005
4004
        currentWall=new gNetPlayerWall(this,pos,dirDrive,lastTime,distance);
4006
4005
 
4056
4055
static tSettingItem<float> conf_zombieZoneRise ("ZOMBIE_ZONE_RISE", sg_zombieZoneRise);
4057
4056
 
4058
4057
static float sg_zombieZoneFall = 1;
4059
 
static tSettingItem<float> conf_zombieZoneFall ("ZOMBIE_ZONE_FALL", sg_zombieZoneFall);
 
4058
static tSettingItem<float> conf_zombieZoneFall ("ZOMBIE_ZONE_FALL", sg_zombieZoneFall);
4060
4059
 
4061
4060
void gCycle::Killed(gCycle *pKiller, int type)
4062
4061
{
4130
4129
            pZone->RequestSync();
4131
4130
        }
4132
4131
    }
4133
 
}
4134
 
 
4135
 
static eLadderLogWriter se_cycleDestroyedWriter("CYCLE_DESTROYED", false);
4136
 
 
4137
 
bool sg_cycleRespawnZone = false;
4138
 
static tSettingItem<bool> sg_cycleRespawnZoneConf("CYCLE_RESPAWN_ZONE", sg_cycleRespawnZone);
4139
 
 
4140
 
bool sg_cycleRespawnZoneType = false;
4141
 
static tSettingItem<bool> sg_cycleRespawnZoneTypeConf("CYCLE_RESPAWN_ZONE_TYPE", sg_cycleRespawnZoneType);
4142
 
 
4143
 
float sg_cycleRespawnZoneRadius = 2.5;
4144
 
static tSettingItem<float> sg_cycleRespawnZoneRadiusConf("CYCLE_RESPAWN_ZONE_RADIUS", sg_cycleRespawnZoneRadius);
4145
 
 
4146
 
float sg_cycleRespawnZoneGrowth = -0.4;
4147
 
static tSettingItem<float> sg_cycleRespawnZoneGrowthConf("CYCLE_RESPAWN_ZONE_GROWTH", sg_cycleRespawnZoneGrowth);
4148
 
 
4149
 
static void sg_cycleRespawnZone_Create(gCycle *cycle)
4150
 
{
4151
 
    eGrid *grid = eGrid::CurrentGrid();
4152
 
    if (!grid) return;
4153
 
 
4154
 
    if (!sg_cycleRespawnZone) return;
4155
 
 
4156
 
    //con << "Cycle respawn zone activated...\n";
4157
 
    ePlayerNetID *player = cycle->Player();
4158
 
 
4159
 
    eCoord resPos, resDir;
4160
 
    if (sg_cycleRespawnZoneType)
4161
 
    {
4162
 
        resPos = cycle->StartPosition();
4163
 
        resDir = cycle->StartDirection();
4164
 
    }
4165
 
    else
4166
 
    {
4167
 
        resPos = cycle->Position();
4168
 
        resDir = cycle->Direction();
4169
 
    }
4170
 
 
4171
 
    if (player)
4172
 
    {
4173
 
        gRespawnZoneHack *cycleRespawnZone = new gRespawnZoneHack(grid, resPos, player, true);
4174
 
        cycleRespawnZone->SetRadius(sg_cycleRespawnZoneRadius * gArena::SizeMultiplier());
4175
 
        cycleRespawnZone->SetExpansionSpeed(sg_cycleRespawnZoneGrowth);
4176
 
        cycleRespawnZone->SetColor(cycle->color_);
4177
 
        cycleRespawnZone->SetSpawnDirection(resDir);
4178
 
 
4179
 
        cycleRespawnZone->RequestSync();
4180
 
    }
4181
 
}
 
4132
}
 
4133
 
 
4134
static eLadderLogWriter se_cycleDestroyedWriter("CYCLE_DESTROYED", false);
 
4135
 
 
4136
bool sg_cycleRespawnZone = false;
 
4137
static tSettingItem<bool> sg_cycleRespawnZoneConf("CYCLE_RESPAWN_ZONE", sg_cycleRespawnZone);
 
4138
 
 
4139
bool sg_cycleRespawnZoneType = false;
 
4140
static tSettingItem<bool> sg_cycleRespawnZoneTypeConf("CYCLE_RESPAWN_ZONE_TYPE", sg_cycleRespawnZoneType);
 
4141
 
 
4142
float sg_cycleRespawnZoneRadius = 2.5;
 
4143
static tSettingItem<float> sg_cycleRespawnZoneRadiusConf("CYCLE_RESPAWN_ZONE_RADIUS", sg_cycleRespawnZoneRadius);
 
4144
 
 
4145
float sg_cycleRespawnZoneGrowth = -0.4;
 
4146
static tSettingItem<float> sg_cycleRespawnZoneGrowthConf("CYCLE_RESPAWN_ZONE_GROWTH", sg_cycleRespawnZoneGrowth);
 
4147
 
 
4148
static void sg_cycleRespawnZone_Create(gCycle *cycle)
 
4149
{
 
4150
    eGrid *grid = eGrid::CurrentGrid();
 
4151
    if (!grid) return;
 
4152
 
 
4153
    if (!sg_cycleRespawnZone) return;
 
4154
 
 
4155
    //con << "Cycle respawn zone activated...\n";
 
4156
    ePlayerNetID *player = cycle->Player();
 
4157
 
 
4158
    eCoord resPos, resDir;
 
4159
    if (sg_cycleRespawnZoneType)
 
4160
    {
 
4161
        resPos = cycle->StartPosition();
 
4162
        resDir = cycle->StartDirection();
 
4163
    }
 
4164
    else
 
4165
    {
 
4166
        resPos = cycle->Position();
 
4167
        resDir = cycle->Direction();
 
4168
    }
 
4169
 
 
4170
    if (player)
 
4171
    {
 
4172
        gRespawnZoneHack *cycleRespawnZone = new gRespawnZoneHack(grid, resPos, player, true);
 
4173
        cycleRespawnZone->SetRadius(sg_cycleRespawnZoneRadius * gArena::SizeMultiplier());
 
4174
        cycleRespawnZone->SetExpansionSpeed(sg_cycleRespawnZoneGrowth);
 
4175
        cycleRespawnZone->SetColor(cycle->color_);
 
4176
        cycleRespawnZone->SetSpawnDirection(resDir);
 
4177
 
 
4178
        cycleRespawnZone->RequestSync();
 
4179
    }
 
4180
}
4182
4181
 
4183
4182
void gCycle::Kill(){
4184
4183
    // keep this cycle alive
4185
4184
    tJUST_CONTROLLED_PTR< gCycle > keep( this->GetRefcount()>0 ? this : 0 );
4186
4185
 
4187
 
    if (sn_GetNetState() != nCLIENT)
 
4186
    if (sn_GetNetState() != nCLIENT)
4188
4187
    {
4189
4188
        RequestSync(true);
4190
4189
 
4195
4194
            flag_->OwnerDropped();
4196
4195
        }
4197
4196
 
4198
 
        if (Alive() && grid && GOID() >= 0 )
 
4197
        if (Alive() && grid && GOID() >= 0 )
4199
4198
        {
4200
4199
            if (sg_deathShot)
4201
4200
            {
4211
4210
 
4212
4211
            Die( lastTime );
4213
4212
            tNEW(gExplosion)(grid, pos,lastTime, color_, this );
4214
 
            //   eEdge::SeethroughHasChanged();
4215
 
 
4216
 
            if (this && Player())
4217
 
            {
4218
 
                tString logTurnsMsg;
4219
 
                logTurnsMsg << "death " << MapPosition().x << " " << MapPosition().y << " " << MapDirection().x << " " << MapDirection().y;
4220
 
                LogPlayersCycleTurns(this, logTurnsMsg);
4221
 
/*
4222
 
                se_cycleDestroyedWriter << Player()->GetUserName() << MapPosition().x << MapPosition().y << MapDirection().x << MapDirection().y << (Player()->CurrentTeam()?ePlayerNetID::FilterName(Team()->Name()):"") << se_GameTime();
4223
 
                se_cycleDestroyedWriter.write();
4224
 
*/
4225
 
                Player()->LogActivity(ACTIVITY_DIED);
4226
 
 
4227
 
                sg_cycleRespawnZone_Create(this);
4228
 
 
4229
 
                if (sg_RaceTimerEnabled)
4230
 
                {
4231
 
                    gRace::ZoneOut(Player(), lastTime);
4232
 
                }
4233
 
            }
 
4213
            //   eEdge::SeethroughHasChanged();
 
4214
 
 
4215
            if (this && Player())
 
4216
            {
 
4217
                tString logTurnsMsg;
 
4218
                logTurnsMsg << "death " << MapPosition().x << " " << MapPosition().y << " " << MapDirection().x << " " << MapDirection().y;
 
4219
                LogPlayersCycleTurns(this, logTurnsMsg);
 
4220
 
 
4221
                se_cycleDestroyedWriter << Player()->GetUserName() << MapPosition().x << MapPosition().y << MapDirection().x << MapDirection().y << ePlayerNetID::FilterName(Team()->Name()) << se_GameTime();
 
4222
                se_cycleDestroyedWriter.write();
 
4223
 
 
4224
                Player()->LogActivity(ACTIVITY_DIED);
 
4225
 
 
4226
                sg_cycleRespawnZone_Create(this);
 
4227
 
 
4228
                if (sg_RaceTimerEnabled)
 
4229
                {
 
4230
                    gRace::ZoneOut(Player(), lastTime);
 
4231
                }
 
4232
            }
4234
4233
 
4235
4234
 
4236
4235
            if ( currentWall )
4586
4585
 
4587
4586
    // render walls with display list
4588
4587
    RenderAll( camera, cycle, wallsWithDisplayList_ );
4589
 
}
4590
 
 
4591
 
bool sg_HideCyclesWalls = false;
 
4588
}
 
4589
 
 
4590
bool sg_HideCyclesWalls = false;
4592
4591
static tConfItem<bool> sg_HideCyclesWallsConf("HIDE_CYCLES_WALLS", sg_HideCyclesWalls);
4593
4592
 
4594
4593
void gCycleWallsDisplayListManager::RenderAll( eCamera const * camera, gCycle * cycle, gNetPlayerWall * list )
4606
4605
    gNetPlayerWall * run = list;
4607
4606
    while( run )
4608
4607
    {
4609
 
        gNetPlayerWall * next = run->Next();
4610
 
 
4611
 
        if (sg_HideCyclesWalls && camera->Player()->Object())
4612
 
        {
4613
 
            if ((camera->Player()->Object()->Alive()) && (camera->Player() != run->Cycle()->Player()))
4614
 
            {
4615
 
                run = next;
4616
 
                continue;
4617
 
            }
 
4608
        gNetPlayerWall * next = run->Next();
 
4609
 
 
4610
        if (sg_HideCyclesWalls && camera->Player()->Object())
 
4611
        {
 
4612
            if ((camera->Player()->Object()->Alive()) && (camera->Player() != run->Cycle()->Player()))
 
4613
            {
 
4614
                run = next;
 
4615
                continue;
 
4616
            }
4618
4617
        }
4619
4618
        run->RenderList( true, gNetPlayerWall::gWallRenderMode_Lines );
4620
4619
        run = next;
4628
4627
    run = list;
4629
4628
    while( run )
4630
4629
    {
4631
 
        gNetPlayerWall * next = run->Next();
4632
 
        if (sg_HideCyclesWalls && camera->Player()->Object())
4633
 
        {
4634
 
            if ((camera->Player()->Object()->Alive()) && (camera->Player() != run->Cycle()->Player()))
4635
 
            {
4636
 
                run = next;
4637
 
                continue;
4638
 
            }
 
4630
        gNetPlayerWall * next = run->Next();
 
4631
        if (sg_HideCyclesWalls && camera->Player()->Object())
 
4632
        {
 
4633
            if ((camera->Player()->Object()->Alive()) && (camera->Player() != run->Cycle()->Player()))
 
4634
            {
 
4635
                run = next;
 
4636
                continue;
 
4637
            }
4639
4638
        }
4640
4639
        run->RenderList( true, gNetPlayerWall::gWallRenderMode_Quads );
4641
4640
        run = next;
4651
4650
 
4652
4651
    // then, render the rest
4653
4652
    RenderAll( camera, cycle, wallList_ );
4654
 
}
4655
 
 
4656
 
bool sg_HideCycles = false;
 
4653
}
 
4654
 
 
4655
bool sg_HideCycles = false;
4657
4656
static tConfItem<bool> sg_HideCyclesConf("HIDE_CYCLES", sg_HideCycles);
4658
4657
 
4659
 
// Should we hide the chat flag above the player's cycle when the user is silenced?
4660
 
static bool se_HideSilencedPyramidChatFlag = true;
4661
 
static tSettingItem<bool> se_HideSilencedPyramidChatFlagConf("HIDE_SILENCED_PYRAMID_CHATFLAG", se_HideSilencedPyramidChatFlag);
4662
 
 
4663
 
 
4664
4658
void gCycle::Render(const eCamera *cam){
4665
4659
    /*
4666
4660
    // for use when there's rendering problems on one specific occasion
4670
4664
    {
4671
4665
        st_Breakpoint();
4672
4666
    }
4673
 
    */
4674
 
 
4675
 
    //  check whether to display other players or not
4676
 
    if (sg_HideCycles && (cam->Player() != this->Player()))
4677
 
        if (cam->Player()->Object() && cam->Player()->Object()->Alive())
 
4667
    */
 
4668
 
 
4669
    //  check whether to display other players or not
 
4670
    if (sg_HideCycles && (cam->Player() != this->Player()))
 
4671
        if (cam->Player()->Object() && cam->Player()->Object()->Alive())
4678
4672
            return;
4679
4673
 
4680
4674
    // are we blinking from invulnerability?
4868
4862
            REAL alpha = 1;
4869
4863
            const REAL timeout = .5f;
4870
4864
 
4871
 
            if (bool(player))
 
4865
            if ( bool(player) )
4872
4866
            {
4873
 
                // If the HIDE_SILENCED_PYRAMID_CHATFLAG command is set to false and the player is not silenced, show the tab chatflag.
4874
 
                if (!(se_HideSilencedPyramidChatFlag && player->AccessSilenced()))
4875
 
                {
4876
 
                    if (player->IsChatting())
4877
 
                    {
4878
 
                        renderPyramid = true;
4879
 
                        colorPyramid.b = 0.0f;
4880
 
                    }
4881
 
                    else if (!player->IsActive())
4882
 
                    {
4883
 
                        renderPyramid = true;
4884
 
                        colorPyramid.b = 0.0f;
4885
 
                        colorPyramid.g = 0.0f;
4886
 
                    }
4887
 
                    else if (cam && cam->Center() == this && se_GameTime() < timeout && player->CurrentTeam() && player->CurrentTeam()->NumPlayers() > 1)
4888
 
                    {
4889
 
                        renderPyramid = true;
4890
 
                        alpha = timeout - se_GameTime();
4891
 
                    }
 
4867
                if ( player->IsChatting() )
 
4868
                {
 
4869
                    renderPyramid = true;
 
4870
                    colorPyramid.b = 0.0f;
 
4871
                }
 
4872
                else if ( !player->IsActive() )
 
4873
                {
 
4874
                    renderPyramid = true;
 
4875
                    colorPyramid.b = 0.0f;
 
4876
                    colorPyramid.g = 0.0f;
 
4877
                }
 
4878
                else if ( cam && cam->Center() == this && se_GameTime() < timeout && player->CurrentTeam() && player->CurrentTeam()->NumPlayers() > 1 )
 
4879
                {
 
4880
                    renderPyramid = true;
 
4881
                    alpha = timeout - se_GameTime();
4892
4882
                }
4893
4883
            }
 
4884
 
4894
4885
            if ( renderPyramid )
4895
4886
            {
4896
4887
                GLfloat s=sin(lastTime);
5147
5138
 
5148
5139
static tSettingItem< bool > sg_showOwnName( "SHOW_OWN_NAME", showOwnName );
5149
5140
static tSettingItem< REAL > sg_fadeOutNameAfter( "FADEOUT_NAME_DELAY", fadeOutNameAfter );
5150
 
 
 
5141
 
5151
5142
// show colored names on cycles?
5152
5143
static bool sg_showColoredName = true;
5153
5144
static tSettingItem< bool > sg_showColoredNameConf( "SHOW_COLORED_NAMES", sg_showColoredName );
5204
5195
    }
5205
5196
 
5206
5197
    /* it is visible */
5207
 
 
 
5198
 
5208
5199
    bool doname = true;
5209
5200
    if (fadeOutNameAfter > 0) {
5210
5201
        REAL now = tSysTimeFloat();
5229
5220
    glLoadIdentity();
5230
5221
 
5231
5222
    /*glColor4f(1, 1, 1, alpha);
5232
 
    DisplayText(xp, yp, rCWIDTH_NORMAL, rCHEIGHT_NORMAL, this->player->GetName(), 0, 0);*/
 
5223
    DisplayText(xp, yp, rCWIDTH_NORMAL, rCHEIGHT_NORMAL, this->player->GetName(), 0, 0);*/
5233
5224
    glTranslatef(xp, yp, 0.);
5234
5225
    if(doname) {
5235
5226
        glColor4f(1, 1, 1, alpha);
5237
5228
        if(sg_showColoredName)
5238
5229
            name << this->player->GetColoredName();
5239
5230
        else
5240
 
            name << this->player->GetName();
 
5231
            name << this->player->GetName();
5241
5232
        DisplayText(0, 0, rCWIDTH_NORMAL, rCHEIGHT_NORMAL, name, 0, 0);
5242
5233
    }
5243
5234
 
5433
5424
 
5434
5425
    nextSync = nextSyncOwner = -1;
5435
5426
    flag_ = NULL;
5436
 
    lastSyncOwnerGameTime_ = 0;
5437
 
 
5438
 
    startPos_ = this->pos;
5439
 
    startDir_ = this->dir;
5440
 
 
5441
 
    tString logTurnsMsg;
5442
 
    logTurnsMsg << "spawned " << this->MapPosition().x << " " << this->MapPosition().y << " " << this->MapDirection().x << " " << this->MapDirection().y;
5443
 
    LogPlayersCycleTurns(this, logTurnsMsg);
5444
 
 
5445
 
    turnedPositions.push_back(startPos_);
 
5427
    lastSyncOwnerGameTime_ = 0;
 
5428
 
 
5429
    startPos_ = this->pos;
 
5430
    startDir_ = this->dir;
 
5431
 
 
5432
    tString logTurnsMsg;
 
5433
    logTurnsMsg << "spawned " << this->MapPosition().x << " " << this->MapPosition().y << " " << this->MapDirection().x << " " << this->MapDirection().y;
 
5434
    LogPlayersCycleTurns(this, logTurnsMsg);
 
5435
 
 
5436
    turnedPositions.push_back(startPos_);
5446
5437
    turnedDirections.push_back(startDir_);
5447
5438
}
5448
5439
 
5729
5720
 
5730
5721
    // delegate
5731
5722
    CopyFrom( *extrapolator_ );
5732
 
 
5733
 
    if (sg_cycleWallTime >= 0)
5734
 
    {
 
5723
 
 
5724
    if (sg_cycleWallTime >= 0)
 
5725
    {
5735
5726
        // adjust current wall (not essential, don't do it for the first wall)
5736
5727
        if ( currentWall && (currentWall->tBeg > (spawnTime_ + sg_cycleWallTime + .01f) ) )
5737
5728
        {
5752
5743
                if ( coord.Pos <= dBeg )
5753
5744
                    coord.Pos = dBeg;
5754
5745
            }
5755
 
        }
5756
 
    }
5757
 
    else currentWall = NULL;
 
5746
        }
 
5747
    }
 
5748
    else currentWall = NULL;
5758
5749
 
5759
5750
 
5760
5751
    // transfer last turn position
5937
5928
        correctDistanceSmooth=0;
5938
5929
        DropWall( false );
5939
5930
 
5940
 
        tNEW(gExplosion)( grid, lastSyncMessage_.pos, lastSyncMessage_.time ,color_, this );
5941
 
 
5942
 
        tString logTurnsMsg;
5943
 
        logTurnsMsg << "death " << this->MapPosition().x << " " << this->MapPosition().y << " " << this->MapDirection().x << " " << this->MapDirection().y;
 
5931
        tNEW(gExplosion)( grid, lastSyncMessage_.pos, lastSyncMessage_.time ,color_, this );
 
5932
 
 
5933
        tString logTurnsMsg;
 
5934
        logTurnsMsg << "death " << this->MapPosition().x << " " << this->MapPosition().y << " " << this->MapDirection().x << " " << this->MapDirection().y;
5944
5935
        LogPlayersCycleTurns(this, logTurnsMsg);
5945
5936
 
5946
5937
        return;
6291
6282
        // create new wall at sync location
6292
6283
        distance = lastSyncMessage_.distance;
6293
6284
        correctDistanceSmooth=0;
6294
 
 
 
6285
 
6295
6286
        REAL startBuildWallAt = spawnTime_ + sg_cycleWallTime;
6296
6287
        if ( crossTime > startBuildWallAt )
6297
6288
            currentWall=new gNetPlayerWall
6679
6670
static tSettingItem<int> conf_megashotDirections ("MEGA_SHOT_DIR", sg_megashotDirections);
6680
6671
 
6681
6672
static int sg_megashotExplosion = 1;
6682
 
static tSettingItem<int> conf_megashotExplosion ("MEGA_SHOT_EXPLOSION", sg_megashotExplosion);
6683
 
 
6684
 
static bool sg_shotPenetrateWalls = false;
6685
 
static tSettingItem<bool> sg_shotPenetrateWallsConf("SHOT_PENETRATE_WALLS", sg_shotPenetrateWalls);
6686
 
 
 
6673
static tSettingItem<int> conf_megashotExplosion ("MEGA_SHOT_EXPLOSION", sg_megashotExplosion);
 
6674
 
 
6675
static bool sg_shotPenetrateWalls = false;
 
6676
static tSettingItem<bool> sg_shotPenetrateWallsConf("SHOT_PENETRATE_WALLS", sg_shotPenetrateWalls);
 
6677
 
6687
6678
static eLadderLogWriter sg_ZoneShotReleased("ZONE_SHOT_RELEASED", false);
6688
6679
 
6689
6680
#define FIX_BRAKE_BUG
6797
6788
                pZone->SetRotationSpeed(shotRotation);
6798
6789
                pZone->SetColor(shotColor);
6799
6790
                pZone->SetOwner(Player());
6800
 
                pZone->SetType(type);
6801
 
 
6802
 
                pZone->SetWallPenetrate(sg_shotPenetrateWalls);
6803
 
 
6804
 
                //  write to laddderlog
6805
 
                sg_ZoneShotReleased << deathShot << pZone->GOID() << Player()->GetUserName() << pZone->MapPosition().x << pZone->MapPosition().y << pZone->GetVelocity().x << pZone->GetVelocity().y;
 
6791
                pZone->SetType(type);
 
6792
 
 
6793
                pZone->SetWallPenetrate(sg_shotPenetrateWalls);
 
6794
 
 
6795
                //  write to laddderlog
 
6796
                sg_ZoneShotReleased << deathShot << pZone->GOID() << Player()->GetUserName() << pZone->MapPosition().x << pZone->MapPosition().y << pZone->GetVelocity().x << pZone->GetVelocity().y;
6806
6797
                sg_ZoneShotReleased.write();
6807
6798
 
6808
6799
                if (sg_shotExplosion == 1)
6844
6835
                        pZone->SetRotationSpeed(shotRotation);
6845
6836
                        pZone->SetColor(shotColor);
6846
6837
                        pZone->SetOwner(Player());
6847
 
                        pZone->SetType(type);
6848
 
 
6849
 
                        pZone->SetWallPenetrate(sg_shotPenetrateWalls);
6850
 
 
6851
 
                        //  write to laddderlog
6852
 
                        sg_ZoneShotReleased << deathShot << pZone->GOID() << Player()->GetUserName() << pZone->MapPosition().x << pZone->MapPosition().y << pZone->GetVelocity().x << pZone->GetVelocity().y;
 
6838
                        pZone->SetType(type);
 
6839
 
 
6840
                        pZone->SetWallPenetrate(sg_shotPenetrateWalls);
 
6841
 
 
6842
                        //  write to laddderlog
 
6843
                        sg_ZoneShotReleased << deathShot << pZone->GOID() << Player()->GetUserName() << pZone->MapPosition().x << pZone->MapPosition().y << pZone->GetVelocity().x << pZone->GetVelocity().y;
6853
6844
                        sg_ZoneShotReleased.write();
6854
6845
 
6855
6846
                        if (sg_megashotExplosion >= 2)
7058
7049
        if (!nwall) {
7059
7050
                DropWall();
7060
7051
                if ((CurrentWall()) && (CurrentWall()->NetWall())) CurrentWall()->NetWall()->RequestSync();
7061
 
        }
 
7052
        }
7062
7053
 
7063
7054
        RequestSync();
7064
7055
}
7078
7069
        int pos = 0; //
7079
7070
        tString PlayerName = ePlayerNetID::FilterName(params.ExtractNonBlankSubString(pos));
7080
7071
        ePlayerNetID *pPlayer = ePlayerNetID::FindPlayerByName(PlayerName);
7081
 
 
7082
 
        if (!pPlayer || !pPlayer->CanRespawn())
7083
 
        {
7084
 
            return;
7085
 
        }
 
7072
        if(!pPlayer)
 
7073
            return;
7086
7074
 
7087
7075
        //const tString message_str = params.ExtractNonBlankSubString(pos);
7088
7076
        //int message = atoi(message_str);
7104
7092
 
7105
7093
        // let's respawn now ...
7106
7094
        if (!pPlayer->Object() || !pPlayer->Object()->Alive())
7107
 
        {
7108
 
            pPlayer->ClearRespawn();
 
7095
        {
 
7096
            pPlayer->ClearRespawn();
7109
7097
 
7110
7098
            gCycle *pCycle = new gCycle(grid, ppos, pdir, pPlayer);
7111
7099
            pPlayer->ControlObject(pCycle);
7116
7104
 
7117
7105
                // send a console message to the player
7118
7106
                sn_CenterMessage(tOutput("$player_respawn_center_message"), pPlayer->Owner());
7119
 
            }
 
7107
            }
7120
7108
            */
7121
7109
        }
7122
7110
}
7181
7169
static tConfItemFunc sg_TeleportPlayer_conf("TELEPORT_PLAYER",&sg_TeleportPlayer);
7182
7170
 
7183
7171
 
7184
 
static void sg_setCycleSpeed(std::istream &s)
7185
 
{
7186
 
    tString playerStr, speedStr;
7187
 
    s >> playerStr;
7188
 
 
7189
 
    ePlayerNetID *player = ePlayerNetID::FindPlayerByName(playerStr);
7190
 
 
7191
 
    if (player)
7192
 
    {
7193
 
        gCycle *pCycle = dynamic_cast<gCycle *>(player->Object());
7194
 
        if (pCycle && pCycle->Alive())
7195
 
        {
7196
 
            s >> speedStr;
7197
 
            REAL speed = atof(speedStr);
7198
 
            if (speed <= 0) speed = 0;
7199
 
 
7200
 
            pCycle->verletSpeed_ = speed;
7201
 
            pCycle->RequestSync();
7202
 
        }
7203
 
    }
7204
 
}
7205
 
static tConfItemFunc sg_setCycleSpeedConf("SET_CYCLE_SPEED", sg_setCycleSpeed);
7206
 
 
7207
 
static void sg_setCycleRubber(std::istream &s)
7208
 
{
7209
 
    tString playerStr, rubberStr;
7210
 
    s >> playerStr;
7211
 
 
7212
 
    ePlayerNetID *player = ePlayerNetID::FindPlayerByName(playerStr);
7213
 
 
7214
 
    if (player)
7215
 
    {
7216
 
        gCycle *pCycle = dynamic_cast<gCycle *>(player->Object());
7217
 
        if (pCycle && pCycle->Alive())
7218
 
        {
7219
 
            s >> rubberStr;
7220
 
            REAL rubber = atof(rubberStr);
7221
 
            if (rubber < 0) rubber = 0;
7222
 
 
7223
 
            pCycle->SetRubber(rubber);
7224
 
            pCycle->RequestSync();
7225
 
        }
7226
 
    }
7227
 
}
7228
 
static tConfItemFunc sg_setCycleRubberConf("SET_CYCLE_RUBBER", sg_setCycleRubber);
 
7172
static void sg_setCycleSpeed(std::istream &s)
 
7173
{
 
7174
    tString playerStr, speedStr;
 
7175
    s >> playerStr;
 
7176
 
 
7177
    ePlayerNetID *player = ePlayerNetID::FindPlayerByName(playerStr);
 
7178
 
 
7179
    if (player)
 
7180
    {
 
7181
        gCycle *pCycle = dynamic_cast<gCycle *>(player->Object());
 
7182
        if (pCycle && pCycle->Alive())
 
7183
        {
 
7184
            s >> speedStr;
 
7185
            REAL speed = atof(speedStr);
 
7186
            if (speed <= 0) speed = 0;
 
7187
 
 
7188
            pCycle->verletSpeed_ = speed;
 
7189
            pCycle->RequestSync();
 
7190
        }
 
7191
    }
 
7192
}
 
7193
static tConfItemFunc sg_setCycleSpeedConf("SET_CYCLE_SPEED", sg_setCycleSpeed);
 
7194
 
 
7195
static void sg_setCycleRubber(std::istream &s)
 
7196
{
 
7197
    tString playerStr, rubberStr;
 
7198
    s >> playerStr;
 
7199
 
 
7200
    ePlayerNetID *player = ePlayerNetID::FindPlayerByName(playerStr);
 
7201
 
 
7202
    if (player)
 
7203
    {
 
7204
        gCycle *pCycle = dynamic_cast<gCycle *>(player->Object());
 
7205
        if (pCycle && pCycle->Alive())
 
7206
        {
 
7207
            s >> rubberStr;
 
7208
            REAL rubber = atof(rubberStr);
 
7209
            if (rubber < 0) rubber = 0;
 
7210
 
 
7211
            pCycle->SetRubber(rubber);
 
7212
            pCycle->RequestSync();
 
7213
        }
 
7214
    }
 
7215
}
 
7216
static tConfItemFunc sg_setCycleRubberConf("SET_CYCLE_RUBBER", sg_setCycleRubber);