Use make_unique
to construct unique_ptr
This commit is contained in:
parent
725ee9f706
commit
b4dcec2e1c
@ -111,19 +111,20 @@ namespace spades {
|
||||
renderer->SetFogDistance(128.f);
|
||||
renderer->SetFogColor(MakeVector3(.8f, 1.f, 1.f));
|
||||
|
||||
chatWindow.reset(
|
||||
new ChatWindow(this, &GetRenderer(), &fontManager->GetGuiFont(), false));
|
||||
killfeedWindow.reset(
|
||||
new ChatWindow(this, &GetRenderer(), &fontManager->GetGuiFont(), true));
|
||||
chatWindow = stmp::make_unique<ChatWindow>(this, &GetRenderer(),
|
||||
&fontManager->GetGuiFont(), false);
|
||||
killfeedWindow =
|
||||
stmp::make_unique<ChatWindow>(this, &GetRenderer(), &fontManager->GetGuiFont(), true);
|
||||
|
||||
hurtRingView.reset(new HurtRingView(this));
|
||||
centerMessageView.reset(new CenterMessageView(this, &fontManager->GetLargeFont()));
|
||||
mapView.reset(new MapView(this, false));
|
||||
largeMapView.reset(new MapView(this, true));
|
||||
scoreboard.reset(new ScoreboardView(this));
|
||||
limbo.reset(new LimboView(this));
|
||||
paletteView.reset(new PaletteView(this));
|
||||
tcView.reset(new TCProgressView(this));
|
||||
hurtRingView = stmp::make_unique<HurtRingView>(this);
|
||||
centerMessageView =
|
||||
stmp::make_unique<CenterMessageView>(this, &fontManager->GetLargeFont());
|
||||
mapView = stmp::make_unique<MapView>(this, false);
|
||||
largeMapView = stmp::make_unique<MapView>(this, true);
|
||||
scoreboard = stmp::make_unique<ScoreboardView>(this);
|
||||
limbo = stmp::make_unique<LimboView>(this);
|
||||
paletteView = stmp::make_unique<PaletteView>(this);
|
||||
tcView = stmp::make_unique<TCProgressView>(this);
|
||||
scriptedUI.Set(new ClientUI(renderer.GetPointerOrNull(), audioDev.GetPointerOrNull(),
|
||||
fontManager.GetPointerOrNull(), this),
|
||||
false);
|
||||
@ -334,7 +335,7 @@ namespace spades {
|
||||
mumbleLink.setIdentity(playerName);
|
||||
|
||||
SPLog("Started connecting to '%s'", hostname.ToString(true).c_str());
|
||||
net.reset(new NetClient(this));
|
||||
net = stmp::make_unique<NetClient>(this);
|
||||
net->Connect(hostname);
|
||||
|
||||
// decide log file name
|
||||
|
@ -419,7 +419,9 @@ namespace spades {
|
||||
|
||||
void SetWorld(World *);
|
||||
World *GetWorld() const { return world.get(); }
|
||||
void AddLocalEntity(ILocalEntity *ent) { localEntities.emplace_back(ent); }
|
||||
void AddLocalEntity(std::unique_ptr<ILocalEntity> &&ent) {
|
||||
localEntities.emplace_back(std::move(ent));
|
||||
}
|
||||
|
||||
void MarkWorldUpdate();
|
||||
|
||||
|
@ -1259,11 +1259,11 @@ namespace spades {
|
||||
default: break;
|
||||
}
|
||||
|
||||
ILocalEntity *ent;
|
||||
ent =
|
||||
new GunCasing(&client, model.GetPointerOrNull(), snd.GetPointerOrNull(),
|
||||
snd2.GetPointerOrNull(), origin, p.GetFront(), vel);
|
||||
client.AddLocalEntity(ent);
|
||||
auto ent = stmp::make_unique<GunCasing>(
|
||||
&client, model.GetPointerOrNull(), snd.GetPointerOrNull(),
|
||||
snd2.GetPointerOrNull(), origin, p.GetFront(), vel);
|
||||
|
||||
client.AddLocalEntity(std::move(ent));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ namespace spades {
|
||||
Handle<IImage> img = renderer->RegisterImage("Gfx/White.tga");
|
||||
Vector4 color = {0.5f, 0.02f, 0.04f, 1.f};
|
||||
for (int i = 0; i < 10; i++) {
|
||||
ParticleSpriteEntity *ent = new ParticleSpriteEntity(this, img, color);
|
||||
auto ent = stmp::make_unique<ParticleSpriteEntity>(this, img, color);
|
||||
ent->SetTrajectory(v,
|
||||
MakeVector3(SampleRandomFloat() - SampleRandomFloat(),
|
||||
SampleRandomFloat() - SampleRandomFloat(),
|
||||
@ -169,7 +169,7 @@ namespace spades {
|
||||
ent->SetRotation(SampleRandomFloat() * (float)M_PI * 2.f);
|
||||
ent->SetRadius(0.1f + SampleRandomFloat() * SampleRandomFloat() * 0.2f);
|
||||
ent->SetLifeTime(3.f, 0.f, 1.f);
|
||||
localEntities.emplace_back(ent);
|
||||
localEntities.emplace_back(std::move(ent));
|
||||
}
|
||||
|
||||
if ((int)cg_particles < 2)
|
||||
@ -177,8 +177,7 @@ namespace spades {
|
||||
|
||||
color = MakeVector4(.7f, .35f, .37f, .6f);
|
||||
for (int i = 0; i < 2; i++) {
|
||||
ParticleSpriteEntity *ent =
|
||||
new SmokeSpriteEntity(this, color, 100.f, SmokeSpriteEntity::Type::Explosion);
|
||||
auto ent = stmp::make_unique<SmokeSpriteEntity>(this, color, 100.f, SmokeSpriteEntity::Type::Explosion);
|
||||
ent->SetTrajectory(v,
|
||||
MakeVector3(SampleRandomFloat() - SampleRandomFloat(),
|
||||
SampleRandomFloat() - SampleRandomFloat(),
|
||||
@ -189,13 +188,12 @@ namespace spades {
|
||||
ent->SetRadius(.5f + SampleRandomFloat() * SampleRandomFloat() * 0.2f, 2.f);
|
||||
ent->SetBlockHitAction(BlockHitAction::Ignore);
|
||||
ent->SetLifeTime(.20f + SampleRandomFloat() * .2f, 0.06f, .20f);
|
||||
localEntities.emplace_back(ent);
|
||||
localEntities.emplace_back(std::move(ent));
|
||||
}
|
||||
|
||||
color.w *= .1f;
|
||||
for (int i = 0; i < 1; i++) {
|
||||
ParticleSpriteEntity *ent =
|
||||
new SmokeSpriteEntity(this, color, 40.f, SmokeSpriteEntity::Type::Steady);
|
||||
auto ent = stmp::make_unique<SmokeSpriteEntity>(this, color, 40.f, SmokeSpriteEntity::Type::Steady);
|
||||
ent->SetTrajectory(v,
|
||||
MakeVector3(SampleRandomFloat() - SampleRandomFloat(),
|
||||
SampleRandomFloat() - SampleRandomFloat(),
|
||||
@ -206,7 +204,7 @@ namespace spades {
|
||||
ent->SetRadius(.7f + SampleRandomFloat() * SampleRandomFloat() * 0.2f, 2.f, 0.1f);
|
||||
ent->SetBlockHitAction(BlockHitAction::Ignore);
|
||||
ent->SetLifeTime(.80f + SampleRandomFloat() * 0.4f, 0.06f, 1.0f);
|
||||
localEntities.emplace_back(ent);
|
||||
localEntities.emplace_back(std::move(ent));
|
||||
}
|
||||
}
|
||||
|
||||
@ -224,7 +222,7 @@ namespace spades {
|
||||
Handle<IImage> img = renderer->RegisterImage("Gfx/White.tga");
|
||||
Vector4 color = {c.x / 255.f, c.y / 255.f, c.z / 255.f, 1.f};
|
||||
for (int i = 0; i < 7; i++) {
|
||||
ParticleSpriteEntity *ent = new ParticleSpriteEntity(this, img, color);
|
||||
auto ent = stmp::make_unique<ParticleSpriteEntity>(this, img, color);
|
||||
ent->SetTrajectory(origin,
|
||||
MakeVector3(SampleRandomFloat() - SampleRandomFloat(),
|
||||
SampleRandomFloat() - SampleRandomFloat(),
|
||||
@ -236,7 +234,7 @@ namespace spades {
|
||||
ent->SetLifeTime(2.f, 0.f, 1.f);
|
||||
if (distPowered < 16.f * 16.f)
|
||||
ent->SetBlockHitAction(BlockHitAction::BounceWeak);
|
||||
localEntities.emplace_back(ent);
|
||||
localEntities.emplace_back(std::move(ent));
|
||||
}
|
||||
|
||||
if ((int)cg_particles < 2)
|
||||
@ -244,7 +242,7 @@ namespace spades {
|
||||
|
||||
if (distPowered < 32.f * 32.f) {
|
||||
for (int i = 0; i < 16; i++) {
|
||||
ParticleSpriteEntity *ent = new ParticleSpriteEntity(this, img, color);
|
||||
auto ent = stmp::make_unique<ParticleSpriteEntity>(this, img, color);
|
||||
ent->SetTrajectory(origin,
|
||||
MakeVector3(SampleRandomFloat() - SampleRandomFloat(),
|
||||
SampleRandomFloat() - SampleRandomFloat(),
|
||||
@ -256,14 +254,14 @@ namespace spades {
|
||||
ent->SetLifeTime(2.f, 0.f, 1.f);
|
||||
if (distPowered < 16.f * 16.f)
|
||||
ent->SetBlockHitAction(BlockHitAction::BounceWeak);
|
||||
localEntities.emplace_back(ent);
|
||||
localEntities.emplace_back(std::move(ent));
|
||||
}
|
||||
}
|
||||
|
||||
color += (MakeVector4(1, 1, 1, 1) - color) * .2f;
|
||||
color.w *= .2f;
|
||||
for (int i = 0; i < 2; i++) {
|
||||
ParticleSpriteEntity *ent = new SmokeSpriteEntity(this, color, 100.f);
|
||||
auto ent = stmp::make_unique<SmokeSpriteEntity>(this, color, 100.f);
|
||||
ent->SetTrajectory(origin,
|
||||
MakeVector3(SampleRandomFloat() - SampleRandomFloat(),
|
||||
SampleRandomFloat() - SampleRandomFloat(),
|
||||
@ -274,7 +272,7 @@ namespace spades {
|
||||
ent->SetRadius(.6f + SampleRandomFloat() * SampleRandomFloat() * 0.2f, 0.8f);
|
||||
ent->SetLifeTime(.3f + SampleRandomFloat() * .3f, 0.06f, .4f);
|
||||
ent->SetBlockHitAction(BlockHitAction::Ignore);
|
||||
localEntities.emplace_back(ent);
|
||||
localEntities.emplace_back(std::move(ent));
|
||||
}
|
||||
}
|
||||
|
||||
@ -293,7 +291,7 @@ namespace spades {
|
||||
Handle<IImage> img = renderer->RegisterImage("Gfx/White.tga");
|
||||
Vector4 color = {c.x / 255.f, c.y / 255.f, c.z / 255.f, 1.f};
|
||||
for (int i = 0; i < 8; i++) {
|
||||
ParticleSpriteEntity *ent = new ParticleSpriteEntity(this, img, color);
|
||||
auto ent = stmp::make_unique<ParticleSpriteEntity>(this, img, color);
|
||||
ent->SetTrajectory(origin,
|
||||
MakeVector3(SampleRandomFloat() - SampleRandomFloat(),
|
||||
SampleRandomFloat() - SampleRandomFloat(),
|
||||
@ -304,7 +302,7 @@ namespace spades {
|
||||
ent->SetRadius(0.3f + SampleRandomFloat() * SampleRandomFloat() * 0.2f);
|
||||
ent->SetLifeTime(2.f, 0.f, 1.f);
|
||||
ent->SetBlockHitAction(BlockHitAction::BounceWeak);
|
||||
localEntities.emplace_back(ent);
|
||||
localEntities.emplace_back(std::move(ent));
|
||||
}
|
||||
}
|
||||
|
||||
@ -325,8 +323,8 @@ namespace spades {
|
||||
|
||||
// rapid smoke
|
||||
for (int i = 0; i < 2; i++) {
|
||||
ParticleSpriteEntity *ent =
|
||||
new SmokeSpriteEntity(this, color, 120.f, SmokeSpriteEntity::Type::Explosion);
|
||||
auto ent = stmp::make_unique<SmokeSpriteEntity>(this, color, 120.f,
|
||||
SmokeSpriteEntity::Type::Explosion);
|
||||
ent->SetTrajectory(origin,
|
||||
(MakeVector3(SampleRandomFloat() - SampleRandomFloat(),
|
||||
SampleRandomFloat() - SampleRandomFloat(),
|
||||
@ -338,7 +336,7 @@ namespace spades {
|
||||
ent->SetRadius(.4f, 3.f, 0.0000005f);
|
||||
ent->SetBlockHitAction(BlockHitAction::Ignore);
|
||||
ent->SetLifeTime(0.2f + SampleRandomFloat() * 0.1f, 0.f, .30f);
|
||||
localEntities.emplace_back(ent);
|
||||
localEntities.emplace_back(std::move(ent));
|
||||
}
|
||||
}
|
||||
|
||||
@ -390,8 +388,8 @@ namespace spades {
|
||||
color = MakeVector4(.6f, .6f, .6f, 1.f);
|
||||
// rapid smoke
|
||||
for (int i = 0; i < 4; i++) {
|
||||
ParticleSpriteEntity *ent =
|
||||
new SmokeSpriteEntity(this, color, 60.f, SmokeSpriteEntity::Type::Explosion);
|
||||
auto ent = stmp::make_unique<SmokeSpriteEntity>(this, color, 60.f,
|
||||
SmokeSpriteEntity::Type::Explosion);
|
||||
ent->SetTrajectory(origin,
|
||||
(MakeVector3(SampleRandomFloat() - SampleRandomFloat(),
|
||||
SampleRandomFloat() - SampleRandomFloat(),
|
||||
@ -403,13 +401,13 @@ namespace spades {
|
||||
ent->SetRadius(.6f + SampleRandomFloat() * SampleRandomFloat() * 0.4f, 2.f, .2f);
|
||||
ent->SetBlockHitAction(BlockHitAction::Ignore);
|
||||
ent->SetLifeTime(1.8f + SampleRandomFloat() * 0.1f, 0.f, .20f);
|
||||
localEntities.emplace_back(ent);
|
||||
localEntities.emplace_back(std::move(ent));
|
||||
}
|
||||
|
||||
// slow smoke
|
||||
color.w = .25f;
|
||||
for (int i = 0; i < 8; i++) {
|
||||
ParticleSpriteEntity *ent = new SmokeSpriteEntity(this, color, 20.f);
|
||||
auto ent = stmp::make_unique<SmokeSpriteEntity>(this, color, 20.f);
|
||||
ent->SetTrajectory(
|
||||
origin,
|
||||
(MakeVector3(SampleRandomFloat() - SampleRandomFloat(),
|
||||
@ -426,14 +424,14 @@ namespace spades {
|
||||
case 3:
|
||||
default: ent->SetLifeTime(2.f + SampleRandomFloat() * 5.f, 0.1f, 8.f); break;
|
||||
}
|
||||
localEntities.emplace_back(ent);
|
||||
localEntities.emplace_back(std::move(ent));
|
||||
}
|
||||
|
||||
// fragments
|
||||
Handle<IImage> img = renderer->RegisterImage("Gfx/White.tga");
|
||||
color = MakeVector4(0.01, 0.03, 0, 1.f);
|
||||
for (int i = 0; i < 42; i++) {
|
||||
ParticleSpriteEntity *ent = new ParticleSpriteEntity(this, img, color);
|
||||
auto ent = stmp::make_unique<ParticleSpriteEntity>(this, img, color);
|
||||
Vector3 dir = MakeVector3(SampleRandomFloat() - SampleRandomFloat(),
|
||||
SampleRandomFloat() - SampleRandomFloat(),
|
||||
SampleRandomFloat() - SampleRandomFloat());
|
||||
@ -444,14 +442,14 @@ namespace spades {
|
||||
ent->SetRadius(radius);
|
||||
ent->SetLifeTime(3.5f + SampleRandomFloat() * 2.f, 0.f, 1.f);
|
||||
ent->SetBlockHitAction(BlockHitAction::BounceWeak);
|
||||
localEntities.emplace_back(ent);
|
||||
localEntities.emplace_back(std::move(ent));
|
||||
}
|
||||
|
||||
// fire smoke
|
||||
color = MakeVector4(1.f, .7f, .4f, .2f) * 5.f;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
ParticleSpriteEntity *ent =
|
||||
new SmokeSpriteEntity(this, color, 120.f, SmokeSpriteEntity::Type::Explosion);
|
||||
auto ent = stmp::make_unique<SmokeSpriteEntity>(this, color, 120.f,
|
||||
SmokeSpriteEntity::Type::Explosion);
|
||||
ent->SetTrajectory(origin,
|
||||
(MakeVector3(SampleRandomFloat() - SampleRandomFloat(),
|
||||
SampleRandomFloat() - SampleRandomFloat(),
|
||||
@ -464,7 +462,7 @@ namespace spades {
|
||||
ent->SetBlockHitAction(BlockHitAction::Ignore);
|
||||
ent->SetLifeTime(.18f + SampleRandomFloat() * 0.03f, 0.f, .10f);
|
||||
// ent->SetAdditive(true);
|
||||
localEntities.emplace_back(ent);
|
||||
localEntities.emplace_back(std::move(ent));
|
||||
}
|
||||
}
|
||||
|
||||
@ -486,7 +484,7 @@ namespace spades {
|
||||
if ((int)cg_particles < 2)
|
||||
color.w = .3f;
|
||||
for (int i = 0; i < 7; i++) {
|
||||
ParticleSpriteEntity *ent = new ParticleSpriteEntity(this, img, color);
|
||||
auto ent = stmp::make_unique<ParticleSpriteEntity>(this, img, color);
|
||||
ent->SetTrajectory(origin,
|
||||
(MakeVector3(SampleRandomFloat() - SampleRandomFloat(),
|
||||
SampleRandomFloat() - SampleRandomFloat(),
|
||||
@ -497,7 +495,7 @@ namespace spades {
|
||||
ent->SetRadius(1.5f + SampleRandomFloat() * SampleRandomFloat() * 0.4f, 1.3f);
|
||||
ent->SetBlockHitAction(BlockHitAction::Ignore);
|
||||
ent->SetLifeTime(3.f + SampleRandomFloat() * 0.3f, 0.f, .60f);
|
||||
localEntities.emplace_back(ent);
|
||||
localEntities.emplace_back(std::move(ent));
|
||||
}
|
||||
|
||||
// water2
|
||||
@ -506,7 +504,7 @@ namespace spades {
|
||||
if ((int)cg_particles < 2)
|
||||
color.w = .4f;
|
||||
for (int i = 0; i < 16; i++) {
|
||||
ParticleSpriteEntity *ent = new ParticleSpriteEntity(this, img, color);
|
||||
auto ent = stmp::make_unique<ParticleSpriteEntity>(this, img, color);
|
||||
ent->SetTrajectory(origin,
|
||||
(MakeVector3(SampleRandomFloat() - SampleRandomFloat(),
|
||||
SampleRandomFloat() - SampleRandomFloat(),
|
||||
@ -517,7 +515,7 @@ namespace spades {
|
||||
ent->SetRadius(0.9f + SampleRandomFloat() * SampleRandomFloat() * 0.4f, 0.7f);
|
||||
ent->SetBlockHitAction(BlockHitAction::Ignore);
|
||||
ent->SetLifeTime(3.f + SampleRandomFloat() * 0.3f, .7f, .60f);
|
||||
localEntities.emplace_back(ent);
|
||||
localEntities.emplace_back(std::move(ent));
|
||||
}
|
||||
|
||||
// slow smoke
|
||||
@ -525,7 +523,7 @@ namespace spades {
|
||||
if ((int)cg_particles < 2)
|
||||
color.w = .2f;
|
||||
for (int i = 0; i < 8; i++) {
|
||||
ParticleSpriteEntity *ent = new SmokeSpriteEntity(this, color, 20.f);
|
||||
auto ent = stmp::make_unique<SmokeSpriteEntity>(this, color, 20.f);
|
||||
ent->SetTrajectory(
|
||||
origin,
|
||||
(MakeVector3(SampleRandomFloat() - SampleRandomFloat(),
|
||||
@ -542,14 +540,14 @@ namespace spades {
|
||||
case 3:
|
||||
default: ent->SetLifeTime(6.f + SampleRandomFloat() * 5.f, 0.1f, 8.f); break;
|
||||
}
|
||||
localEntities.emplace_back(ent);
|
||||
localEntities.emplace_back(std::move(ent));
|
||||
}
|
||||
|
||||
// fragments
|
||||
img = renderer->RegisterImage("Gfx/White.tga");
|
||||
color = MakeVector4(1, 1, 1, 0.7f);
|
||||
for (int i = 0; i < 42; i++) {
|
||||
ParticleSpriteEntity *ent = new ParticleSpriteEntity(this, img, color);
|
||||
auto ent = stmp::make_unique<ParticleSpriteEntity>(this, img, color);
|
||||
Vector3 dir = MakeVector3(SampleRandomFloat() - SampleRandomFloat(),
|
||||
SampleRandomFloat() - SampleRandomFloat(),
|
||||
-SampleRandomFloat() * 3.f);
|
||||
@ -561,7 +559,7 @@ namespace spades {
|
||||
ent->SetRadius(radius);
|
||||
ent->SetLifeTime(3.5f + SampleRandomFloat() * 2.f, 0.f, 1.f);
|
||||
ent->SetBlockHitAction(BlockHitAction::Delete);
|
||||
localEntities.emplace_back(ent);
|
||||
localEntities.emplace_back(std::move(ent));
|
||||
}
|
||||
|
||||
// TODO: wave?
|
||||
@ -584,7 +582,7 @@ namespace spades {
|
||||
if ((int)cg_particles < 2)
|
||||
color.w = .2f;
|
||||
for (int i = 0; i < 2; i++) {
|
||||
ParticleSpriteEntity *ent = new ParticleSpriteEntity(this, img, color);
|
||||
auto ent = stmp::make_unique<ParticleSpriteEntity>(this, img, color);
|
||||
ent->SetTrajectory(origin,
|
||||
(MakeVector3(SampleRandomFloat() - SampleRandomFloat(),
|
||||
SampleRandomFloat() - SampleRandomFloat(),
|
||||
@ -595,7 +593,7 @@ namespace spades {
|
||||
ent->SetRadius(0.6f + SampleRandomFloat() * SampleRandomFloat() * 0.4f, .7f);
|
||||
ent->SetBlockHitAction(BlockHitAction::Ignore);
|
||||
ent->SetLifeTime(3.f + SampleRandomFloat() * 0.3f, 0.1f, .60f);
|
||||
localEntities.emplace_back(ent);
|
||||
localEntities.emplace_back(std::move(ent));
|
||||
}
|
||||
|
||||
// water2
|
||||
@ -604,7 +602,7 @@ namespace spades {
|
||||
if ((int)cg_particles < 2)
|
||||
color.w = .4f;
|
||||
for (int i = 0; i < 6; i++) {
|
||||
ParticleSpriteEntity *ent = new ParticleSpriteEntity(this, img, color);
|
||||
auto ent = stmp::make_unique<ParticleSpriteEntity>(this, img, color);
|
||||
ent->SetTrajectory(origin,
|
||||
(MakeVector3(SampleRandomFloat() - SampleRandomFloat(),
|
||||
SampleRandomFloat() - SampleRandomFloat(),
|
||||
@ -616,14 +614,14 @@ namespace spades {
|
||||
ent->SetBlockHitAction(BlockHitAction::Ignore);
|
||||
ent->SetLifeTime(3.f + SampleRandomFloat() * 0.3f, SampleRandomFloat() * 0.3f,
|
||||
.60f);
|
||||
localEntities.emplace_back(ent);
|
||||
localEntities.emplace_back(std::move(ent));
|
||||
}
|
||||
|
||||
// fragments
|
||||
img = renderer->RegisterImage("Gfx/White.tga");
|
||||
color = MakeVector4(1, 1, 1, 0.7f);
|
||||
for (int i = 0; i < 10; i++) {
|
||||
ParticleSpriteEntity *ent = new ParticleSpriteEntity(this, img, color);
|
||||
auto ent = stmp::make_unique<ParticleSpriteEntity>(this, img, color);
|
||||
Vector3 dir = MakeVector3(SampleRandomFloat() - SampleRandomFloat(),
|
||||
SampleRandomFloat() - SampleRandomFloat(),
|
||||
-SampleRandomFloat() * 3.f);
|
||||
@ -634,7 +632,7 @@ namespace spades {
|
||||
ent->SetRadius(radius);
|
||||
ent->SetLifeTime(3.5f + SampleRandomFloat() * 2.f, 0.f, 1.f);
|
||||
ent->SetBlockHitAction(BlockHitAction::Delete);
|
||||
localEntities.emplace_back(ent);
|
||||
localEntities.emplace_back(std::move(ent));
|
||||
}
|
||||
|
||||
// TODO: wave?
|
||||
|
@ -1099,8 +1099,8 @@ namespace spades {
|
||||
case SMG_WEAPON: vel = 360.f; break;
|
||||
case SHOTGUN_WEAPON: vel = 500.f; break;
|
||||
}
|
||||
AddLocalEntity(new Tracer(this, muzzlePos, hitPos, vel));
|
||||
AddLocalEntity(new MapViewTracer(muzzlePos, hitPos, vel));
|
||||
AddLocalEntity(stmp::make_unique<Tracer>(this, muzzlePos, hitPos, vel));
|
||||
AddLocalEntity(stmp::make_unique<MapViewTracer>(muzzlePos, hitPos, vel));
|
||||
}
|
||||
|
||||
void Client::BlocksFell(std::vector<IntVector3> blocks) {
|
||||
@ -1108,8 +1108,7 @@ namespace spades {
|
||||
|
||||
if (blocks.empty())
|
||||
return;
|
||||
FallingBlock *b = new FallingBlock(this, blocks);
|
||||
AddLocalEntity(b);
|
||||
AddLocalEntity(stmp::make_unique<FallingBlock>(this, blocks));
|
||||
|
||||
if (!IsMuted()) {
|
||||
|
||||
|
@ -169,8 +169,7 @@ namespace spades {
|
||||
Vector3 p3 = p2 + vmAxis3 * (float)z;
|
||||
|
||||
{
|
||||
ParticleSpriteEntity *ent =
|
||||
new SmokeSpriteEntity(client, col, 70.f);
|
||||
auto ent = stmp::make_unique<SmokeSpriteEntity>(client, col, 70.f);
|
||||
ent->SetTrajectory(
|
||||
p3,
|
||||
(MakeVector3(getRandom() - getRandom(), getRandom() - getRandom(),
|
||||
@ -181,13 +180,13 @@ namespace spades {
|
||||
ent->SetRadius(1.0f, 0.5f);
|
||||
ent->SetBlockHitAction(BlockHitAction::Ignore);
|
||||
ent->SetLifeTime(1.0f + getRandom() * 0.5f, 0.f, 1.0f);
|
||||
client->AddLocalEntity(ent);
|
||||
client->AddLocalEntity(std::move(ent));
|
||||
}
|
||||
|
||||
col.w = 1.f;
|
||||
for (int i = 0; i < 6; i++) {
|
||||
ParticleSpriteEntity *ent =
|
||||
new ParticleSpriteEntity(client, img.GetPointerOrNull(), col);
|
||||
auto ent = stmp::make_unique<ParticleSpriteEntity>(
|
||||
client, img.GetPointerOrNull(), col);
|
||||
ent->SetTrajectory(p3,
|
||||
MakeVector3(getRandom() - getRandom(),
|
||||
getRandom() - getRandom(),
|
||||
@ -199,7 +198,7 @@ namespace spades {
|
||||
ent->SetLifeTime(2.f, 0.f, 1.f);
|
||||
if (usePrecisePhysics)
|
||||
ent->SetBlockHitAction(BlockHitAction::BounceWeak);
|
||||
client->AddLocalEntity(ent);
|
||||
client->AddLocalEntity(std::move(ent));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ namespace spades {
|
||||
rawDataWriter = StreamHandle{std::get<0>(pipe)};
|
||||
auto rawDataReader = StreamHandle{std::get<1>(pipe)};
|
||||
|
||||
decodingThreadRunnable.reset(new Decoder(*this, rawDataReader));
|
||||
decodingThreadRunnable = stmp::make_unique<Decoder>(*this, rawDataReader);
|
||||
|
||||
// Drop `rawDataReader` before the thread starts. `StreamHandle`'s internally
|
||||
// ref-counted and it's not thread-safe. So, if we don't drop it here, there'll be
|
||||
@ -86,7 +86,7 @@ namespace spades {
|
||||
// variable `rawDataReader`.
|
||||
rawDataReader = StreamHandle{};
|
||||
|
||||
decodingThread.reset(new Thread(&*decodingThreadRunnable));
|
||||
decodingThread = stmp::make_unique<Thread>(&*decodingThreadRunnable);
|
||||
decodingThread->Start();
|
||||
}
|
||||
|
||||
|
@ -39,6 +39,7 @@ namespace spades {
|
||||
width = mp.Width();
|
||||
height = mp.Height();
|
||||
depth = mp.Depth();
|
||||
// TODO: `stmp::make_unique` doesn't support array initialization yet
|
||||
linkMap.reset(new uint8_t[width * height * depth]);
|
||||
memset(linkMap.get(), 0, width * height * depth);
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ namespace spades {
|
||||
Vector3 pt = matrix.GetOrigin();
|
||||
pt.z = 62.99f;
|
||||
for (int i = 0; i < splats; i++) {
|
||||
ParticleSpriteEntity *ent = new ParticleSpriteEntity(client, img, col);
|
||||
auto ent = stmp::make_unique<ParticleSpriteEntity>(client, img, col);
|
||||
ent->SetTrajectory(
|
||||
pt,
|
||||
MakeVector3(SampleRandomFloat() - SampleRandomFloat(),
|
||||
@ -127,7 +127,7 @@ namespace spades {
|
||||
ent->SetRotation(SampleRandomFloat() * (float)M_PI * 2.f);
|
||||
ent->SetRadius(0.1f + SampleRandomFloat() * SampleRandomFloat() * 0.1f);
|
||||
ent->SetLifeTime(2.f, 0.f, 1.f);
|
||||
client->AddLocalEntity(ent);
|
||||
client->AddLocalEntity(std::move(ent));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,7 @@ namespace spades {
|
||||
|
||||
map = newMap;
|
||||
if (map) {
|
||||
mapWrapper.reset(new GameMapWrapper(*map));
|
||||
mapWrapper = stmp::make_unique<GameMapWrapper>(*map);
|
||||
mapWrapper->Rebuild();
|
||||
}
|
||||
}
|
||||
@ -470,7 +470,7 @@ namespace spades {
|
||||
HitTestDebugger *World::GetHitTestDebugger() {
|
||||
if (cg_debugHitTest) {
|
||||
if (hitTestDebugger == nullptr) {
|
||||
hitTestDebugger.reset(new HitTestDebugger(this));
|
||||
hitTestDebugger = stmp::make_unique<HitTestDebugger>(this);
|
||||
}
|
||||
return hitTestDebugger.get();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user