Convert space indentations to tabs
This commit is contained in:
parent
29c42d950b
commit
18f3e81fd1
@ -168,25 +168,25 @@ namespace al{
|
|||||||
static void *GPA(const char *str)
|
static void *GPA(const char *str)
|
||||||
{
|
{
|
||||||
if(!alLibrary){
|
if(!alLibrary){
|
||||||
auto paths = spades::Split(s_alDriver, ";");
|
auto paths = spades::Split(s_alDriver, ";");
|
||||||
std::string errors;
|
std::string errors;
|
||||||
for (const std::string &path: paths) {
|
for (const std::string &path: paths) {
|
||||||
auto trimmedPath = spades::TrimSpaces(path);
|
auto trimmedPath = spades::TrimSpaces(path);
|
||||||
try {
|
try {
|
||||||
alLibrary = new spades::DynamicLibrary(trimmedPath.c_str());
|
alLibrary = new spades::DynamicLibrary(trimmedPath.c_str());
|
||||||
if (alLibrary) {
|
if (alLibrary) {
|
||||||
SPLog("'%s' loaded", trimmedPath.c_str());
|
SPLog("'%s' loaded", trimmedPath.c_str());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} catch (const std::exception &ex) {
|
} catch (const std::exception &ex) {
|
||||||
errors += trimmedPath;
|
errors += trimmedPath;
|
||||||
errors += ":\n";
|
errors += ":\n";
|
||||||
errors += ex.what();
|
errors += ex.what();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!alLibrary) {
|
if (!alLibrary) {
|
||||||
SPRaise("Failed to load a OpenAL driver.\n%s", errors.c_str());
|
SPRaise("Failed to load a OpenAL driver.\n%s", errors.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(qalGetProcAddress){
|
if(qalGetProcAddress){
|
||||||
|
@ -338,24 +338,24 @@ namespace spades {
|
|||||||
|
|
||||||
if(actualWeapInput.secondary && player->IsToolWeapon() &&
|
if(actualWeapInput.secondary && player->IsToolWeapon() &&
|
||||||
player->IsAlive()){
|
player->IsAlive()){
|
||||||
// This is the only animation that can be turned off
|
// This is the only animation that can be turned off
|
||||||
// here; others affect the gameplay directly and
|
// here; others affect the gameplay directly and
|
||||||
// turning them off would be considered cheating
|
// turning them off would be considered cheating
|
||||||
if (cg_animations) {
|
if (cg_animations) {
|
||||||
aimDownState += dt * 8.f;
|
aimDownState += dt * 8.f;
|
||||||
if(aimDownState > 1.f)
|
if(aimDownState > 1.f)
|
||||||
aimDownState = 1.f;
|
aimDownState = 1.f;
|
||||||
} else {
|
} else {
|
||||||
aimDownState = 1.f;
|
aimDownState = 1.f;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
if (cg_animations) {
|
if (cg_animations) {
|
||||||
aimDownState -= dt * 3.f;
|
aimDownState -= dt * 3.f;
|
||||||
if(aimDownState < 0.f)
|
if(aimDownState < 0.f)
|
||||||
aimDownState = 0.f;
|
aimDownState = 0.f;
|
||||||
} else {
|
} else {
|
||||||
aimDownState = 0.f;
|
aimDownState = 0.f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(currentTool == player->GetTool()) {
|
if(currentTool == player->GetTool()) {
|
||||||
|
@ -412,14 +412,14 @@ namespace spades {
|
|||||||
(!w->IsReloading()) &&
|
(!w->IsReloading()) &&
|
||||||
world->GetLocalPlayer()->GetTool() == Player::ToolWeapon){
|
world->GetLocalPlayer()->GetTool() == Player::ToolWeapon){
|
||||||
if(world->GetLocalPlayer()->IsToolWeapon()){
|
if(world->GetLocalPlayer()->IsToolWeapon()){
|
||||||
if(weapInput.secondary) {
|
if(weapInput.secondary) {
|
||||||
// if we send WeaponInput after sending Reload,
|
// if we send WeaponInput after sending Reload,
|
||||||
// server might cancel the reload.
|
// server might cancel the reload.
|
||||||
// https://github.com/infogulch/pyspades/blob/895879ed14ddee47bb278a77be86d62c7580f8b7/pyspades/server.py#343
|
// https://github.com/infogulch/pyspades/blob/895879ed14ddee47bb278a77be86d62c7580f8b7/pyspades/server.py#343
|
||||||
hasDelayedReload = true;
|
hasDelayedReload = true;
|
||||||
weapInput.secondary = false;
|
weapInput.secondary = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
world->GetLocalPlayer()->Reload();
|
world->GetLocalPlayer()->Reload();
|
||||||
net->SendReload();
|
net->SendReload();
|
||||||
|
@ -145,8 +145,8 @@ namespace spades {
|
|||||||
150.f * 150.f)
|
150.f * 150.f)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ((int)cg_particles < 1)
|
if ((int)cg_particles < 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Handle<IImage> img = renderer->RegisterImage("Gfx/White.tga");
|
Handle<IImage> img = renderer->RegisterImage("Gfx/White.tga");
|
||||||
Vector4 color = {0.5f, 0.02f, 0.04f, 1.f};
|
Vector4 color = {0.5f, 0.02f, 0.04f, 1.f};
|
||||||
@ -162,10 +162,10 @@ namespace spades {
|
|||||||
ent->SetRadius(0.1f + GetRandom()*GetRandom()*0.2f);
|
ent->SetRadius(0.1f + GetRandom()*GetRandom()*0.2f);
|
||||||
ent->SetLifeTime(3.f, 0.f, 1.f);
|
ent->SetLifeTime(3.f, 0.f, 1.f);
|
||||||
localEntities.emplace_back(ent);
|
localEntities.emplace_back(ent);
|
||||||
}
|
}
|
||||||
|
|
||||||
if((int) cg_particles < 2)
|
if((int) cg_particles < 2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
color = MakeVector4(.7f, .35f, .37f, .6f);
|
color = MakeVector4(.7f, .35f, .37f, .6f);
|
||||||
for(int i = 0; i < 2; i++){
|
for(int i = 0; i < 2; i++){
|
||||||
@ -214,8 +214,8 @@ namespace spades {
|
|||||||
150.f * 150.f)
|
150.f * 150.f)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ((int)cg_particles < 1)
|
if ((int)cg_particles < 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Handle<IImage> img = renderer->RegisterImage("Gfx/White.tga");
|
Handle<IImage> img = renderer->RegisterImage("Gfx/White.tga");
|
||||||
Vector4 color = {c.x / 255.f,
|
Vector4 color = {c.x / 255.f,
|
||||||
@ -236,8 +236,8 @@ namespace spades {
|
|||||||
localEntities.emplace_back(ent);
|
localEntities.emplace_back(ent);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((int)cg_particles < 2)
|
if ((int)cg_particles < 2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(distPowered <
|
if(distPowered <
|
||||||
32.f * 32.f){
|
32.f * 32.f){
|
||||||
@ -289,8 +289,8 @@ namespace spades {
|
|||||||
150.f * 150.f)
|
150.f * 150.f)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ((int)cg_particles < 1)
|
if ((int)cg_particles < 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Handle<IImage> img = renderer->RegisterImage("Gfx/White.tga");
|
Handle<IImage> img = renderer->RegisterImage("Gfx/White.tga");
|
||||||
Vector4 color = {c.x / 255.f,
|
Vector4 color = {c.x / 255.f,
|
||||||
@ -321,8 +321,8 @@ namespace spades {
|
|||||||
l.color = MakeVector3(3.f, 1.6f, 0.5f);
|
l.color = MakeVector3(3.f, 1.6f, 0.5f);
|
||||||
flashDlights.push_back(l);
|
flashDlights.push_back(l);
|
||||||
|
|
||||||
if ((int)cg_particles < 1)
|
if ((int)cg_particles < 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Vector4 color;
|
Vector4 color;
|
||||||
Vector3 velBias = {0, 0, -0.5f};
|
Vector3 velBias = {0, 0, -0.5f};
|
||||||
@ -363,8 +363,8 @@ namespace spades {
|
|||||||
l.useLensFlare = true;
|
l.useLensFlare = true;
|
||||||
flashDlights.push_back(l);
|
flashDlights.push_back(l);
|
||||||
|
|
||||||
if ((int)cg_particles < 1)
|
if ((int)cg_particles < 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Vector3 velBias = {0,0,0};
|
Vector3 velBias = {0,0,0};
|
||||||
if(!map->ClipBox(origin.x, origin.y, origin.z)){
|
if(!map->ClipBox(origin.x, origin.y, origin.z)){
|
||||||
@ -422,18 +422,18 @@ namespace spades {
|
|||||||
ent->SetRadius(1.5f + GetRandom()*GetRandom()*0.8f,
|
ent->SetRadius(1.5f + GetRandom()*GetRandom()*0.8f,
|
||||||
0.2f);
|
0.2f);
|
||||||
ent->SetBlockHitAction(ParticleSpriteEntity::Ignore);
|
ent->SetBlockHitAction(ParticleSpriteEntity::Ignore);
|
||||||
switch ((int) cg_particles) {
|
switch ((int) cg_particles) {
|
||||||
case 1:
|
case 1:
|
||||||
ent->SetLifeTime(0.8f + GetRandom() * 1.f, 0.1f, 8.f);
|
ent->SetLifeTime(0.8f + GetRandom() * 1.f, 0.1f, 8.f);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
ent->SetLifeTime(1.5f + GetRandom() * 2.f, 0.1f, 8.f);
|
ent->SetLifeTime(1.5f + GetRandom() * 2.f, 0.1f, 8.f);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
default:
|
default:
|
||||||
ent->SetLifeTime(2.f + GetRandom() * 5.f, 0.1f, 8.f);
|
ent->SetLifeTime(2.f + GetRandom() * 5.f, 0.1f, 8.f);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
localEntities.emplace_back(ent);
|
localEntities.emplace_back(ent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -487,17 +487,17 @@ namespace spades {
|
|||||||
if(grenadeVibration > 1.f)
|
if(grenadeVibration > 1.f)
|
||||||
grenadeVibration = 1.f;
|
grenadeVibration = 1.f;
|
||||||
|
|
||||||
if((int) cg_particles < 1)
|
if((int) cg_particles < 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Vector3 velBias = {0,0,0};
|
Vector3 velBias = {0,0,0};
|
||||||
|
|
||||||
Vector4 color;
|
Vector4 color;
|
||||||
color = MakeVector4( .95f, .95f, .95f, .6f);
|
color = MakeVector4( .95f, .95f, .95f, .6f);
|
||||||
// water1
|
// water1
|
||||||
Handle<IImage> img = renderer->RegisterImage("Textures/WaterExpl.png");
|
Handle<IImage> img = renderer->RegisterImage("Textures/WaterExpl.png");
|
||||||
if((int) cg_particles < 2)
|
if((int) cg_particles < 2)
|
||||||
color.w = .3f;
|
color.w = .3f;
|
||||||
for(int i = 0; i < 7; i++){
|
for(int i = 0; i < 7; i++){
|
||||||
ParticleSpriteEntity *ent =
|
ParticleSpriteEntity *ent =
|
||||||
new ParticleSpriteEntity(this, img, color);
|
new ParticleSpriteEntity(this, img, color);
|
||||||
@ -518,7 +518,7 @@ namespace spades {
|
|||||||
img = renderer->RegisterImage("Textures/Fluid.png");
|
img = renderer->RegisterImage("Textures/Fluid.png");
|
||||||
color.w = .9f;
|
color.w = .9f;
|
||||||
if((int) cg_particles < 2)
|
if((int) cg_particles < 2)
|
||||||
color.w = .4f;
|
color.w = .4f;
|
||||||
for(int i = 0; i < 16; i++){
|
for(int i = 0; i < 16; i++){
|
||||||
ParticleSpriteEntity *ent =
|
ParticleSpriteEntity *ent =
|
||||||
new ParticleSpriteEntity(this, img, color);
|
new ParticleSpriteEntity(this, img, color);
|
||||||
@ -536,9 +536,9 @@ namespace spades {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// slow smoke
|
// slow smoke
|
||||||
color.w = .4f;
|
color.w = .4f;
|
||||||
if((int) cg_particles < 2)
|
if((int) cg_particles < 2)
|
||||||
color.w = .2f;
|
color.w = .2f;
|
||||||
for(int i = 0; i < 8; i++){
|
for(int i = 0; i < 8; i++){
|
||||||
ParticleSpriteEntity *ent =
|
ParticleSpriteEntity *ent =
|
||||||
new SmokeSpriteEntity(this, color, 20.f);
|
new SmokeSpriteEntity(this, color, 20.f);
|
||||||
@ -551,17 +551,17 @@ namespace spades {
|
|||||||
ent->SetRadius(1.4f + GetRandom()*GetRandom()*0.8f,
|
ent->SetRadius(1.4f + GetRandom()*GetRandom()*0.8f,
|
||||||
0.2f);
|
0.2f);
|
||||||
ent->SetBlockHitAction(ParticleSpriteEntity::Ignore);
|
ent->SetBlockHitAction(ParticleSpriteEntity::Ignore);
|
||||||
switch ((int)cg_particles) {
|
switch ((int)cg_particles) {
|
||||||
case 1:
|
case 1:
|
||||||
ent->SetLifeTime(3.f + GetRandom() * 5.f, 0.1f, 8.f);
|
ent->SetLifeTime(3.f + GetRandom() * 5.f, 0.1f, 8.f);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
case 3:
|
case 3:
|
||||||
default:
|
default:
|
||||||
ent->SetLifeTime(6.f + GetRandom() * 5.f, 0.1f, 8.f);
|
ent->SetLifeTime(6.f + GetRandom() * 5.f, 0.1f, 8.f);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
localEntities.emplace_back(ent);
|
localEntities.emplace_back(ent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -599,8 +599,8 @@ namespace spades {
|
|||||||
if(!cg_waterImpact)
|
if(!cg_waterImpact)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if((int) cg_particles < 1)
|
if((int) cg_particles < 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Vector4 color;
|
Vector4 color;
|
||||||
color = MakeVector4( .95f, .95f, .95f, .3f);
|
color = MakeVector4( .95f, .95f, .95f, .3f);
|
||||||
|
@ -101,12 +101,12 @@ namespace spades {
|
|||||||
SceneDefinition Client::CreateSceneDefinition() {
|
SceneDefinition Client::CreateSceneDefinition() {
|
||||||
SPADES_MARK_FUNCTION();
|
SPADES_MARK_FUNCTION();
|
||||||
|
|
||||||
int shakeLevel = cg_shake;
|
int shakeLevel = cg_shake;
|
||||||
|
|
||||||
SceneDefinition def;
|
SceneDefinition def;
|
||||||
def.time = (unsigned int)(time * 1000.f);
|
def.time = (unsigned int)(time * 1000.f);
|
||||||
def.denyCameraBlur = true;
|
def.denyCameraBlur = true;
|
||||||
def.zFar = 200.f;
|
def.zFar = 200.f;
|
||||||
|
|
||||||
if(world){
|
if(world){
|
||||||
IntVector3 fogColor = world->GetFogColor();
|
IntVector3 fogColor = world->GetFogColor();
|
||||||
@ -257,32 +257,32 @@ namespace spades {
|
|||||||
Vector3 right = player->GetRight();
|
Vector3 right = player->GetRight();
|
||||||
Vector3 up = player->GetUp();
|
Vector3 up = player->GetUp();
|
||||||
|
|
||||||
if (shakeLevel >= 1) {
|
if (shakeLevel >= 1) {
|
||||||
float localFireVibration = GetLocalFireVibration();
|
float localFireVibration = GetLocalFireVibration();
|
||||||
localFireVibration *= localFireVibration;
|
localFireVibration *= localFireVibration;
|
||||||
|
|
||||||
if(player->GetTool() == Player::ToolSpade) {
|
if(player->GetTool() == Player::ToolSpade) {
|
||||||
localFireVibration *= 0.4f;
|
localFireVibration *= 0.4f;
|
||||||
}
|
}
|
||||||
|
|
||||||
roll += (nextRandom() - nextRandom()) * 0.03f * localFireVibration;
|
roll += (nextRandom() - nextRandom()) * 0.03f * localFireVibration;
|
||||||
scale += nextRandom() * 0.04f * localFireVibration;
|
scale += nextRandom() * 0.04f * localFireVibration;
|
||||||
|
|
||||||
vibPitch += localFireVibration * (1.f - localFireVibration) * 0.01f;
|
vibPitch += localFireVibration * (1.f - localFireVibration) * 0.01f;
|
||||||
vibYaw += sinf(localFireVibration * (float)M_PI * 2.f) * 0.001f;
|
vibYaw += sinf(localFireVibration * (float)M_PI * 2.f) * 0.001f;
|
||||||
|
|
||||||
def.radialBlur += localFireVibration * 0.2f;
|
def.radialBlur += localFireVibration * 0.2f;
|
||||||
|
|
||||||
// sprint bob
|
// sprint bob
|
||||||
{
|
{
|
||||||
float sp = SmoothStep(GetSprintState());
|
float sp = SmoothStep(GetSprintState());
|
||||||
vibYaw += sinf(player->GetWalkAnimationProgress() * static_cast<float>(M_PI) * 2.f) * 0.01f * sp;
|
vibYaw += sinf(player->GetWalkAnimationProgress() * static_cast<float>(M_PI) * 2.f) * 0.01f * sp;
|
||||||
roll -= sinf(player->GetWalkAnimationProgress() * static_cast<float>(M_PI) * 2.f) * 0.005f * (sp);
|
roll -= sinf(player->GetWalkAnimationProgress() * static_cast<float>(M_PI) * 2.f) * 0.005f * (sp);
|
||||||
float p = cosf(player->GetWalkAnimationProgress() * static_cast<float>(M_PI) * 2.f);
|
float p = cosf(player->GetWalkAnimationProgress() * static_cast<float>(M_PI) * 2.f);
|
||||||
p = p * p; p *= p; p *= p; p *= p;
|
p = p * p; p *= p; p *= p; p *= p;
|
||||||
vibPitch += p * 0.01f * sp;
|
vibPitch += p * 0.01f * sp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
scale /= GetAimDownZoomScale();
|
scale /= GetAimDownZoomScale();
|
||||||
|
|
||||||
@ -335,8 +335,8 @@ namespace spades {
|
|||||||
def.viewAxis[0] = right * cosf(roll) - up * sinf(roll);
|
def.viewAxis[0] = right * cosf(roll) - up * sinf(roll);
|
||||||
def.viewAxis[1] = up * cosf(roll) + right * sinf(roll);
|
def.viewAxis[1] = up * cosf(roll) + right * sinf(roll);
|
||||||
|
|
||||||
def.fovX = atanf(tanf(def.fovX * .5f) * scale) * 2.f;
|
def.fovX = atanf(tanf(def.fovX * .5f) * scale) * 2.f;
|
||||||
def.fovY = atanf(tanf(def.fovY * .5f) * scale) * 2.f;
|
def.fovY = atanf(tanf(def.fovY * .5f) * scale) * 2.f;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Vector3 u = def.viewAxis[1];
|
Vector3 u = def.viewAxis[1];
|
||||||
@ -355,13 +355,13 @@ namespace spades {
|
|||||||
{
|
{
|
||||||
float wTime = world->GetTime();
|
float wTime = world->GetTime();
|
||||||
if(wTime < lastHurtTime + .15f &&
|
if(wTime < lastHurtTime + .15f &&
|
||||||
wTime >= lastHurtTime){
|
wTime >= lastHurtTime){
|
||||||
float per = 1.f - (wTime - lastHurtTime) / .15f;
|
float per = 1.f - (wTime - lastHurtTime) / .15f;
|
||||||
per *= .5f - player->GetHealth() / 100.f * .3f;
|
per *= .5f - player->GetHealth() / 100.f * .3f;
|
||||||
def.blurVignette += per * 6.f;
|
def.blurVignette += per * 6.f;
|
||||||
}
|
}
|
||||||
if(wTime < lastHurtTime + .2f &&
|
if(wTime < lastHurtTime + .2f &&
|
||||||
wTime >= lastHurtTime){
|
wTime >= lastHurtTime){
|
||||||
float per = 1.f - (wTime - lastHurtTime) / .2f;
|
float per = 1.f - (wTime - lastHurtTime) / .2f;
|
||||||
per *= .5f - player->GetHealth() / 100.f * .3f;
|
per *= .5f - player->GetHealth() / 100.f * .3f;
|
||||||
def.saturation *= std::max(0.f, 1.f - per * 4.f);
|
def.saturation *= std::max(0.f, 1.f - per * 4.f);
|
||||||
@ -405,10 +405,10 @@ namespace spades {
|
|||||||
renderer->SetFogColor(MakeVector3(0,0,0));
|
renderer->SetFogColor(MakeVector3(0,0,0));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (def.viewOrigin.z < 0.f) {
|
if (def.viewOrigin.z < 0.f) {
|
||||||
// Need to move the far plane because there's no vertical fog
|
// Need to move the far plane because there's no vertical fog
|
||||||
def.zFar -= def.viewOrigin.z;
|
def.zFar -= def.viewOrigin.z;
|
||||||
}
|
}
|
||||||
|
|
||||||
SPAssert(!isnan(def.viewOrigin.x));
|
SPAssert(!isnan(def.viewOrigin.x));
|
||||||
SPAssert(!isnan(def.viewOrigin.y));
|
SPAssert(!isnan(def.viewOrigin.y));
|
||||||
|
@ -617,11 +617,11 @@ namespace spades {
|
|||||||
void Corpse::Update(float dt) {
|
void Corpse::Update(float dt) {
|
||||||
SPADES_MARK_FUNCTION();
|
SPADES_MARK_FUNCTION();
|
||||||
float damp = 1.f;
|
float damp = 1.f;
|
||||||
float damp2 = 1.f;
|
float damp2 = 1.f;
|
||||||
if(dt > 0.f){
|
if(dt > 0.f){
|
||||||
damp = powf(.9f, dt);
|
damp = powf(.9f, dt);
|
||||||
damp2 = powf(.371f, dt);
|
damp2 = powf(.371f, dt);
|
||||||
}
|
}
|
||||||
//dt *= 0.1f;
|
//dt *= 0.1f;
|
||||||
|
|
||||||
for(int i = 0; i <NodeCount; i++){
|
for(int i = 0; i <NodeCount; i++){
|
||||||
@ -637,9 +637,9 @@ namespace spades {
|
|||||||
node.vel.z -= dt * 6.f; // buoyancy
|
node.vel.z -= dt * 6.f; // buoyancy
|
||||||
node.vel *= damp;
|
node.vel *= damp;
|
||||||
}else{
|
}else{
|
||||||
node.vel.z += dt * 32.f; // gravity
|
node.vel.z += dt * 32.f; // gravity
|
||||||
node.vel.z *= damp2;
|
node.vel.z *= damp2;
|
||||||
}
|
}
|
||||||
|
|
||||||
//node.vel *= damp;
|
//node.vel *= damp;
|
||||||
|
|
||||||
|
@ -205,10 +205,10 @@ namespace spades {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static inline bool EqualTwoCond(T a, T b, T c, bool cond) {
|
static inline bool EqualTwoCond(T a, T b, T c, bool cond) {
|
||||||
return a == b || (cond && a == c);
|
return a == b || (cond && a == c);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<CellPos> GameMapWrapper::RemoveBlocks(const std::vector<CellPos>& cells) {
|
std::vector<CellPos> GameMapWrapper::RemoveBlocks(const std::vector<CellPos>& cells) {
|
||||||
SPADES_MARK_FUNCTION();
|
SPADES_MARK_FUNCTION();
|
||||||
@ -227,12 +227,12 @@ namespace spades {
|
|||||||
CellPos pos = cells[i];
|
CellPos pos = cells[i];
|
||||||
m->Set(pos.x, pos.y, pos.z, false, 0);
|
m->Set(pos.x, pos.y, pos.z, false, 0);
|
||||||
// if(GetLink(pos.x, pos.y, pos.z) == Invalid){
|
// if(GetLink(pos.x, pos.y, pos.z) == Invalid){
|
||||||
// this block is already disconnected.
|
// this block is already disconnected.
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if(GetLink(pos.x, pos.y, pos.z) == Marked){
|
if(GetLink(pos.x, pos.y, pos.z) == Marked){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
SPAssert(GetLink(pos.x, pos.y, pos.z) != Root);
|
SPAssert(GetLink(pos.x, pos.y, pos.z) != Root);
|
||||||
|
|
||||||
SetLink(pos.x, pos.y, pos.z, Invalid);
|
SetLink(pos.x, pos.y, pos.z, Invalid);
|
||||||
@ -275,12 +275,12 @@ namespace spades {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove "visited" mark
|
// remove "visited" mark
|
||||||
for(size_t i = 0; i < unlinkedCells.size(); i++){
|
for(size_t i = 0; i < unlinkedCells.size(); i++){
|
||||||
const CellPos& pos = unlinkedCells[i];
|
const CellPos& pos = unlinkedCells[i];
|
||||||
if(GetLink(pos.x, pos.y, pos.z) == Marked)
|
if(GetLink(pos.x, pos.y, pos.z) == Marked)
|
||||||
SetLink(pos.x, pos.y, pos.z, Invalid);
|
SetLink(pos.x, pos.y, pos.z, Invalid);
|
||||||
}
|
}
|
||||||
|
|
||||||
SPAssert(queue.IsEmpty());
|
SPAssert(queue.IsEmpty());
|
||||||
|
|
||||||
|
@ -37,115 +37,115 @@ namespace spades {
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
MumbleLink::MumbleLink() :
|
MumbleLink::MumbleLink() :
|
||||||
metre_per_block(0.63),
|
metre_per_block(0.63),
|
||||||
mumbleLinkedMemory(nullptr),
|
mumbleLinkedMemory(nullptr),
|
||||||
priv(new MumbleLinkPrivate())
|
priv(new MumbleLinkPrivate())
|
||||||
{}
|
{}
|
||||||
|
|
||||||
MumbleLink::~MumbleLink() {
|
MumbleLink::~MumbleLink() {
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
UnmapViewOfFile(mumbleLinkedMemory);
|
UnmapViewOfFile(mumbleLinkedMemory);
|
||||||
if (priv->obj != nullptr)
|
if (priv->obj != nullptr)
|
||||||
CloseHandle(priv->obj);
|
CloseHandle(priv->obj);
|
||||||
#else
|
#else
|
||||||
munmap(mumbleLinkedMemory, sizeof(*mumbleLinkedMemory));
|
munmap(mumbleLinkedMemory, sizeof(*mumbleLinkedMemory));
|
||||||
if (priv->fd > 0)
|
if (priv->fd > 0)
|
||||||
close(priv->fd);
|
close(priv->fd);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void MumbleLink::set_mumble_vector3(float mumble_vec[3],
|
void MumbleLink::set_mumble_vector3(float mumble_vec[3],
|
||||||
const spades::Vector3 &vec) {
|
const spades::Vector3 &vec) {
|
||||||
mumble_vec[0] = vec.x;
|
mumble_vec[0] = vec.x;
|
||||||
mumble_vec[1] = vec.z;
|
mumble_vec[1] = vec.z;
|
||||||
mumble_vec[2] = vec.y;
|
mumble_vec[2] = vec.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MumbleLink::init() {
|
bool MumbleLink::init() {
|
||||||
assert(mumbleLinkedMemory == nullptr);
|
assert(mumbleLinkedMemory == nullptr);
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
priv->obj = OpenFileMappingW(FILE_MAP_ALL_ACCESS, FALSE, L"MumbleLink");
|
priv->obj = OpenFileMappingW(FILE_MAP_ALL_ACCESS, FALSE, L"MumbleLink");
|
||||||
if (priv->obj == nullptr)
|
if (priv->obj == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
mumbleLinkedMemory = static_cast<MumbleLinkedMemory *>(MapViewOfFile(
|
mumbleLinkedMemory = static_cast<MumbleLinkedMemory *>(MapViewOfFile(
|
||||||
priv->obj, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(*mumbleLinkedMemory)));
|
priv->obj, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(*mumbleLinkedMemory)));
|
||||||
|
|
||||||
if (mumbleLinkedMemory == nullptr) {
|
if (mumbleLinkedMemory == nullptr) {
|
||||||
CloseHandle(priv->obj);
|
CloseHandle(priv->obj);
|
||||||
priv->obj = nullptr;
|
priv->obj = nullptr;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
std::string name = "/MumbleLink." + std::to_string(getuid());
|
std::string name = "/MumbleLink." + std::to_string(getuid());
|
||||||
|
|
||||||
priv->fd = shm_open(name.c_str(), O_RDWR, S_IRUSR | S_IWUSR);
|
priv->fd = shm_open(name.c_str(), O_RDWR, S_IRUSR | S_IWUSR);
|
||||||
|
|
||||||
if (priv->fd < 0) {
|
if (priv->fd < 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
mumbleLinkedMemory = static_cast<MumbleLinkedMemory *>(
|
mumbleLinkedMemory = static_cast<MumbleLinkedMemory *>(
|
||||||
(mmap(nullptr, sizeof(*mumbleLinkedMemory), PROT_READ | PROT_WRITE,
|
(mmap(nullptr, sizeof(*mumbleLinkedMemory), PROT_READ | PROT_WRITE,
|
||||||
MAP_SHARED, priv->fd, 0)));
|
MAP_SHARED, priv->fd, 0)));
|
||||||
|
|
||||||
if (mumbleLinkedMemory == MAP_FAILED) {
|
if (mumbleLinkedMemory == MAP_FAILED) {
|
||||||
mumbleLinkedMemory = nullptr;
|
mumbleLinkedMemory = nullptr;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MumbleLink::setContext(const std::string &context) {
|
void MumbleLink::setContext(const std::string &context) {
|
||||||
if (mumbleLinkedMemory == nullptr)
|
if (mumbleLinkedMemory == nullptr)
|
||||||
return;
|
return;
|
||||||
size_t len(std::min(256, static_cast<int>(context.size())));
|
size_t len(std::min(256, static_cast<int>(context.size())));
|
||||||
std::memcpy(mumbleLinkedMemory->context, context.c_str(), len);
|
std::memcpy(mumbleLinkedMemory->context, context.c_str(), len);
|
||||||
mumbleLinkedMemory->context_len = len;
|
mumbleLinkedMemory->context_len = len;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MumbleLink::setIdentity(const std::string &identity) {
|
void MumbleLink::setIdentity(const std::string &identity) {
|
||||||
if (mumbleLinkedMemory == nullptr)
|
if (mumbleLinkedMemory == nullptr)
|
||||||
return;
|
return;
|
||||||
std::wcsncpy(mumbleLinkedMemory->identity,
|
std::wcsncpy(mumbleLinkedMemory->identity,
|
||||||
std::wstring(identity.begin(), identity.end()).c_str(), 256);
|
std::wstring(identity.begin(), identity.end()).c_str(), 256);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MumbleLink::update(spades::client::Player *player) {
|
void MumbleLink::update(spades::client::Player *player) {
|
||||||
if (mumbleLinkedMemory == nullptr || player == nullptr)
|
if (mumbleLinkedMemory == nullptr || player == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (mumbleLinkedMemory->uiVersion != 2) {
|
if (mumbleLinkedMemory->uiVersion != 2) {
|
||||||
wcsncpy(mumbleLinkedMemory->name, L"OpenSpades", 256);
|
wcsncpy(mumbleLinkedMemory->name, L"OpenSpades", 256);
|
||||||
wcsncpy(mumbleLinkedMemory->description, L"OpenSpades Link plugin.", 2048);
|
wcsncpy(mumbleLinkedMemory->description, L"OpenSpades Link plugin.", 2048);
|
||||||
mumbleLinkedMemory->uiVersion = 2;
|
mumbleLinkedMemory->uiVersion = 2;
|
||||||
}
|
}
|
||||||
mumbleLinkedMemory->uiTick++;
|
mumbleLinkedMemory->uiTick++;
|
||||||
|
|
||||||
// Left handed coordinate system.
|
// Left handed coordinate system.
|
||||||
// X positive towards "right".
|
// X positive towards "right".
|
||||||
// Y positive towards "up".
|
// Y positive towards "up".
|
||||||
// Z positive towards "front".
|
// Z positive towards "front".
|
||||||
//
|
//
|
||||||
// 1 unit = 1 meter
|
// 1 unit = 1 meter
|
||||||
|
|
||||||
// Unit vector pointing out of the avatar's eyes aka "At"-vector.
|
// Unit vector pointing out of the avatar's eyes aka "At"-vector.
|
||||||
set_mumble_vector3(mumbleLinkedMemory->fAvatarFront, player->GetFront());
|
set_mumble_vector3(mumbleLinkedMemory->fAvatarFront, player->GetFront());
|
||||||
|
|
||||||
// Unit vector pointing out of the top of the avatar's head aka "Up"-vector
|
// Unit vector pointing out of the top of the avatar's head aka "Up"-vector
|
||||||
// (here Top points straight up).
|
// (here Top points straight up).
|
||||||
set_mumble_vector3(mumbleLinkedMemory->fAvatarTop, player->GetUp());
|
set_mumble_vector3(mumbleLinkedMemory->fAvatarTop, player->GetUp());
|
||||||
|
|
||||||
// Position of the avatar (here standing slightly off the origin)
|
// Position of the avatar (here standing slightly off the origin)
|
||||||
set_mumble_vector3(mumbleLinkedMemory->fAvatarPosition,
|
set_mumble_vector3(mumbleLinkedMemory->fAvatarPosition,
|
||||||
player->GetPosition() * metre_per_block);
|
player->GetPosition() * metre_per_block);
|
||||||
|
|
||||||
// Same as avatar but for the camera.
|
// Same as avatar but for the camera.
|
||||||
set_mumble_vector3(mumbleLinkedMemory->fCameraPosition,
|
set_mumble_vector3(mumbleLinkedMemory->fCameraPosition,
|
||||||
player->GetPosition() * metre_per_block);
|
player->GetPosition() * metre_per_block);
|
||||||
set_mumble_vector3(mumbleLinkedMemory->fCameraFront, player->GetFront());
|
set_mumble_vector3(mumbleLinkedMemory->fCameraFront, player->GetFront());
|
||||||
set_mumble_vector3(mumbleLinkedMemory->fCameraTop, player->GetUp());
|
set_mumble_vector3(mumbleLinkedMemory->fCameraTop, player->GetUp());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1053,15 +1053,15 @@ namespace spades {
|
|||||||
client->LocalPlayerCreated();
|
client->LocalPlayerCreated();
|
||||||
lastPlayerInput = 0xffffffff;
|
lastPlayerInput = 0xffffffff;
|
||||||
lastWeaponInput = 0xffffffff;
|
lastWeaponInput = 0xffffffff;
|
||||||
SendHeldBlockColor(); // ensure block color synchronized
|
SendHeldBlockColor(); // ensure block color synchronized
|
||||||
}else{
|
}else{
|
||||||
if(team < 2 && pId < (int)playerPosRecords.size()) {
|
if(team < 2 && pId < (int)playerPosRecords.size()) {
|
||||||
PosRecord& rec = playerPosRecords[pId];
|
PosRecord& rec = playerPosRecords[pId];
|
||||||
|
|
||||||
rec.valid = true;
|
rec.valid = true;
|
||||||
rec.pos = pos;
|
rec.pos = pos;
|
||||||
rec.time = GetWorld()->GetTime();
|
rec.time = GetWorld()->GetTime();
|
||||||
}
|
}
|
||||||
if(savedPlayerTeam[pId] != team && team < 2){
|
if(savedPlayerTeam[pId] != team && team < 2){
|
||||||
|
|
||||||
client->PlayerJoinedTeam(p);
|
client->PlayerJoinedTeam(p);
|
||||||
@ -1344,7 +1344,7 @@ namespace spades {
|
|||||||
int state = reader.ReadByte();
|
int state = reader.ReadByte();
|
||||||
|
|
||||||
IGameMode* mode = GetWorld()->GetMode();
|
IGameMode* mode = GetWorld()->GetMode();
|
||||||
if(mode == NULL) break;
|
if(mode == NULL) break;
|
||||||
if( mode->ModeType() != IGameMode::m_TC ) {
|
if( mode->ModeType() != IGameMode::m_TC ) {
|
||||||
SPRaise("Received PacketTypeTerritoryCapture in non-TC gamemode");
|
SPRaise("Received PacketTypeTerritoryCapture in non-TC gamemode");
|
||||||
}
|
}
|
||||||
@ -1377,7 +1377,7 @@ namespace spades {
|
|||||||
float progress = reader.ReadFloat();
|
float progress = reader.ReadFloat();
|
||||||
|
|
||||||
IGameMode* mode = GetWorld()->GetMode();
|
IGameMode* mode = GetWorld()->GetMode();
|
||||||
if(mode == NULL) break;
|
if(mode == NULL) break;
|
||||||
if( mode->ModeType() != IGameMode::m_TC ) {
|
if( mode->ModeType() != IGameMode::m_TC ) {
|
||||||
SPRaise("Received PacketTypeProgressBar in non-TC gamemode");
|
SPRaise("Received PacketTypeProgressBar in non-TC gamemode");
|
||||||
}
|
}
|
||||||
@ -1403,7 +1403,7 @@ namespace spades {
|
|||||||
{
|
{
|
||||||
if(!GetWorld()) SPRaise("No world");
|
if(!GetWorld()) SPRaise("No world");
|
||||||
IGameMode* mode = GetWorld()->GetMode();
|
IGameMode* mode = GetWorld()->GetMode();
|
||||||
if(mode == NULL) break;
|
if(mode == NULL) break;
|
||||||
if( mode->ModeType() != IGameMode::m_CTF ) {
|
if( mode->ModeType() != IGameMode::m_CTF ) {
|
||||||
SPRaise("Received PacketTypeIntelCapture in non-TC gamemode");
|
SPRaise("Received PacketTypeIntelCapture in non-TC gamemode");
|
||||||
}
|
}
|
||||||
@ -1423,7 +1423,7 @@ namespace spades {
|
|||||||
{
|
{
|
||||||
Player *p = GetPlayer(reader.ReadByte());
|
Player *p = GetPlayer(reader.ReadByte());
|
||||||
IGameMode* mode = GetWorld()->GetMode();
|
IGameMode* mode = GetWorld()->GetMode();
|
||||||
if(mode == NULL) break;
|
if(mode == NULL) break;
|
||||||
if( mode->ModeType() != IGameMode::m_CTF ) {
|
if( mode->ModeType() != IGameMode::m_CTF ) {
|
||||||
SPRaise("Received PacketTypeIntelPickup in non-TC gamemode");
|
SPRaise("Received PacketTypeIntelPickup in non-TC gamemode");
|
||||||
}
|
}
|
||||||
@ -1438,7 +1438,7 @@ namespace spades {
|
|||||||
{
|
{
|
||||||
Player *p = GetPlayer(reader.ReadByte());
|
Player *p = GetPlayer(reader.ReadByte());
|
||||||
IGameMode* mode = GetWorld()->GetMode();
|
IGameMode* mode = GetWorld()->GetMode();
|
||||||
if(mode == NULL) break;
|
if(mode == NULL) break;
|
||||||
if( mode->ModeType() != IGameMode::m_CTF ) {
|
if( mode->ModeType() != IGameMode::m_CTF ) {
|
||||||
SPRaise("Received PacketTypeIntelPickup in non-TC gamemode");
|
SPRaise("Received PacketTypeIntelPickup in non-TC gamemode");
|
||||||
}
|
}
|
||||||
|
@ -166,10 +166,10 @@ namespace spades {
|
|||||||
if(nextBlockTime > world->GetTime() +
|
if(nextBlockTime > world->GetTime() +
|
||||||
std::max(GetToolPrimaryDelay(),
|
std::max(GetToolPrimaryDelay(),
|
||||||
GetToolSecondaryDelay())) {
|
GetToolSecondaryDelay())) {
|
||||||
nextBlockTime = world->GetTime() +
|
nextBlockTime = world->GetTime() +
|
||||||
std::max(GetToolPrimaryDelay(),
|
std::max(GetToolPrimaryDelay(),
|
||||||
GetToolSecondaryDelay());
|
GetToolSecondaryDelay());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(world->GetTime() < nextBlockTime){
|
if(world->GetTime() < nextBlockTime){
|
||||||
newInput.primary = false;
|
newInput.primary = false;
|
||||||
@ -543,10 +543,10 @@ namespace spades {
|
|||||||
return dist < 8.f;
|
return dist < 8.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
static float GetHorizontalLength(const Vector3 &v)
|
static float GetHorizontalLength(const Vector3 &v)
|
||||||
{
|
{
|
||||||
return std::sqrt(v.x * v.x + v.y * v.y);
|
return std::sqrt(v.x * v.x + v.y * v.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class HitBodyPart {
|
enum class HitBodyPart {
|
||||||
None,
|
None,
|
||||||
@ -622,7 +622,7 @@ namespace spades {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(hb.torso.RayCast(muzzle, dir, &hitPos)) {
|
if(hb.torso.RayCast(muzzle, dir, &hitPos)) {
|
||||||
float dist = GetHorizontalLength(hitPos - muzzle);
|
float dist = GetHorizontalLength(hitPos - muzzle);
|
||||||
if(hitPlayer == NULL ||
|
if(hitPlayer == NULL ||
|
||||||
dist < hitPlayerDistance){
|
dist < hitPlayerDistance){
|
||||||
hitPlayer = other;
|
hitPlayer = other;
|
||||||
@ -709,7 +709,7 @@ namespace spades {
|
|||||||
mapResult.normal);
|
mapResult.normal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else if(hitPlayer != NULL){
|
}else if(hitPlayer != NULL){
|
||||||
if(hitPlayerDistance < 128.f){
|
if(hitPlayerDistance < 128.f){
|
||||||
|
|
||||||
finalHitPos = muzzle + dir * hitPlayerDistance;
|
finalHitPos = muzzle + dir * hitPlayerDistance;
|
||||||
|
@ -50,27 +50,27 @@ DEFINE_SPADES_SETTING(core_numDispatchQueueThreads, "auto");
|
|||||||
|
|
||||||
static int GetNumCores() {
|
static int GetNumCores() {
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
SYSTEM_INFO sysinfo;
|
SYSTEM_INFO sysinfo;
|
||||||
GetSystemInfo(&sysinfo);
|
GetSystemInfo(&sysinfo);
|
||||||
return sysinfo.dwNumberOfProcessors;
|
return sysinfo.dwNumberOfProcessors;
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
int nm[2];
|
int nm[2];
|
||||||
size_t len = 4;
|
size_t len = 4;
|
||||||
uint32_t count;
|
uint32_t count;
|
||||||
|
|
||||||
nm[0] = CTL_HW; nm[1] = HW_AVAILCPU;
|
nm[0] = CTL_HW; nm[1] = HW_AVAILCPU;
|
||||||
sysctl(nm, 2, &count, &len, NULL, 0);
|
sysctl(nm, 2, &count, &len, NULL, 0);
|
||||||
|
|
||||||
if(count < 1) {
|
if(count < 1) {
|
||||||
nm[1] = HW_NCPU;
|
nm[1] = HW_NCPU;
|
||||||
sysctl(nm, 2, &count, &len, NULL, 0);
|
sysctl(nm, 2, &count, &len, NULL, 0);
|
||||||
if(count < 1) { count = 1; }
|
if(count < 1) { count = 1; }
|
||||||
}
|
}
|
||||||
return count;
|
return count;
|
||||||
#elif defined(__linux__)
|
#elif defined(__linux__)
|
||||||
return get_nprocs();
|
return get_nprocs();
|
||||||
#else
|
#else
|
||||||
return sysconf(_SC_NPROCESSORS_ONLN);
|
return sysconf(_SC_NPROCESSORS_ONLN);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,18 +33,18 @@ namespace spades {
|
|||||||
if(!fn) SPInvalidArgument("fn");
|
if(!fn) SPInvalidArgument("fn");
|
||||||
if(fn[0] == 0) SPFileNotFound(fn);
|
if(fn[0] == 0) SPFileNotFound(fn);
|
||||||
|
|
||||||
// check each file systems
|
// check each file systems
|
||||||
for(auto *fs: g_fileSystems){
|
for(auto *fs: g_fileSystems){
|
||||||
if(fs->FileExists(fn))
|
if(fs->FileExists(fn))
|
||||||
return fs->OpenForReading(fn);
|
return fs->OpenForReading(fn);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check weak files, too
|
// check weak files, too
|
||||||
auto weak_fn = std::string(fn) + ".weak";
|
auto weak_fn = std::string(fn) + ".weak";
|
||||||
for(auto *fs: g_fileSystems){
|
for(auto *fs: g_fileSystems){
|
||||||
if(fs->FileExists(weak_fn.c_str()))
|
if(fs->FileExists(weak_fn.c_str()))
|
||||||
return fs->OpenForReading(weak_fn.c_str());
|
return fs->OpenForReading(weak_fn.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
SPFileNotFound(fn);
|
SPFileNotFound(fn);
|
||||||
}
|
}
|
||||||
@ -57,7 +57,7 @@ namespace spades {
|
|||||||
return fs->OpenForWriting(fn);
|
return fs->OpenForWriting(fn);
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: handling of weak files
|
// FIXME: handling of weak files
|
||||||
|
|
||||||
// create file
|
// create file
|
||||||
for(auto *fs: g_fileSystems){
|
for(auto *fs: g_fileSystems){
|
||||||
@ -76,14 +76,14 @@ namespace spades {
|
|||||||
for(auto *fs: g_fileSystems){
|
for(auto *fs: g_fileSystems){
|
||||||
if(fs->FileExists(fn))
|
if(fs->FileExists(fn))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check weak files, too
|
// check weak files, too
|
||||||
auto weak_fn = std::string(fn) + ".weak";
|
auto weak_fn = std::string(fn) + ".weak";
|
||||||
for(auto *fs: g_fileSystems){
|
for(auto *fs: g_fileSystems){
|
||||||
if(fs->FileExists(weak_fn.c_str()))
|
if(fs->FileExists(weak_fn.c_str()))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -26,26 +26,26 @@
|
|||||||
|
|
||||||
namespace spades {
|
namespace spades {
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
ThreadLocalStorage<bool> writeAllowed;
|
ThreadLocalStorage<bool> writeAllowed;
|
||||||
|
|
||||||
// SettingItemDescriptor supplied to ItemHandle must have the static storage duration
|
// SettingItemDescriptor supplied to ItemHandle must have the static storage duration
|
||||||
std::unordered_map<std::string, const SettingItemDescriptor *>
|
std::unordered_map<std::string, const SettingItemDescriptor *>
|
||||||
settingItemDescriptors;
|
settingItemDescriptors;
|
||||||
|
|
||||||
const SettingItemDescriptor *MakeSettingItemDescriptor
|
const SettingItemDescriptor *MakeSettingItemDescriptor
|
||||||
(const std::string &name, const std::string &defaultValue)
|
(const std::string &name, const std::string &defaultValue)
|
||||||
{
|
{
|
||||||
auto it = settingItemDescriptors.find(name);
|
auto it = settingItemDescriptors.find(name);
|
||||||
if (it != settingItemDescriptors.end()) {
|
if (it != settingItemDescriptors.end()) {
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
auto *descriptor = new SettingItemDescriptor(defaultValue, SettingItemFlags::None);
|
auto *descriptor = new SettingItemDescriptor(defaultValue, SettingItemFlags::None);
|
||||||
settingItemDescriptors.insert(make_pair(name, descriptor));
|
settingItemDescriptors.insert(make_pair(name, descriptor));
|
||||||
return descriptor;
|
return descriptor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaskConfigUpdateByScript(bool disabled)
|
void MaskConfigUpdateByScript(bool disabled)
|
||||||
{
|
{
|
||||||
@ -65,13 +65,13 @@ namespace spades {
|
|||||||
|
|
||||||
class ConfigItem: public RefCountedObject {
|
class ConfigItem: public RefCountedObject {
|
||||||
Settings::ItemHandle handle;
|
Settings::ItemHandle handle;
|
||||||
public:
|
public:
|
||||||
ConfigItem(const std::string& name, const std::string& defaultValue):
|
ConfigItem(const std::string& name, const std::string& defaultValue):
|
||||||
handle(name, MakeSettingItemDescriptor(name, defaultValue)){
|
handle(name, MakeSettingItemDescriptor(name, defaultValue)){
|
||||||
}
|
}
|
||||||
ConfigItem(const std::string& name):
|
ConfigItem(const std::string& name):
|
||||||
handle(name, nullptr){
|
handle(name, nullptr){
|
||||||
}
|
}
|
||||||
|
|
||||||
static ConfigItem *Construct(const std::string& name, const std::string& defaultValue) {
|
static ConfigItem *Construct(const std::string& name, const std::string& defaultValue) {
|
||||||
return new ConfigItem(name, defaultValue);
|
return new ConfigItem(name, defaultValue);
|
||||||
@ -133,7 +133,7 @@ namespace spades {
|
|||||||
auto *ctx = asGetActiveContext();
|
auto *ctx = asGetActiveContext();
|
||||||
auto *engine = ctx->GetEngine();
|
auto *engine = ctx->GetEngine();
|
||||||
auto *arrayType = engine->GetTypeInfoByDecl("array<string>");
|
auto *arrayType = engine->GetTypeInfoByDecl("array<string>");
|
||||||
auto *array = CScriptArray::Create(arrayType);
|
auto *array = CScriptArray::Create(arrayType);
|
||||||
auto names = Settings::GetInstance()->GetAllItemNames();
|
auto names = Settings::GetInstance()->GetAllItemNames();
|
||||||
array->Resize(static_cast<asUINT>(names.size()));
|
array->Resize(static_cast<asUINT>(names.size()));
|
||||||
for(std::size_t i = 0; i < names.size(); i++) {
|
for(std::size_t i = 0; i < names.size(); i++) {
|
||||||
|
@ -46,37 +46,37 @@ namespace spades {
|
|||||||
ArrayType *obj = new ArrayType(initialSize);
|
ArrayType *obj = new ArrayType(initialSize);
|
||||||
asGetActiveContext()->GetEngine()->NotifyGarbageCollectorOfNewObject(obj, scrType);
|
asGetActiveContext()->GetEngine()->NotifyGarbageCollectorOfNewObject(obj, scrType);
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
static ArrayType *Factory3(asUINT initialSize, T initialValue) {
|
static ArrayType *Factory3(asUINT initialSize, T initialValue) {
|
||||||
if(initialSize > 1024 * 1024 * 256) {
|
if(initialSize > 1024 * 1024 * 256) {
|
||||||
asGetActiveContext()->SetException("Too many array elements");
|
asGetActiveContext()->SetException("Too many array elements");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
ArrayType *obj = new ArrayType(initialSize, initialValue);
|
ArrayType *obj = new ArrayType(initialSize, initialValue);
|
||||||
asGetActiveContext()->GetEngine()->NotifyGarbageCollectorOfNewObject(obj, scrType);
|
asGetActiveContext()->GetEngine()->NotifyGarbageCollectorOfNewObject(obj, scrType);
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
static ArrayType *Factory4(void *initList) {
|
static ArrayType *Factory4(void *initList) {
|
||||||
asUINT length = *reinterpret_cast<const asUINT *>(initList);
|
asUINT length = *reinterpret_cast<const asUINT *>(initList);
|
||||||
if(length > 1024 * 1024 * 256) {
|
if(length > 1024 * 1024 * 256) {
|
||||||
asGetActiveContext()->SetException("Too many array elements");
|
asGetActiveContext()->SetException("Too many array elements");
|
||||||
}
|
}
|
||||||
ArrayType *obj = new ArrayType(initList);
|
ArrayType *obj = new ArrayType(initList);
|
||||||
asGetActiveContext()->GetEngine()->NotifyGarbageCollectorOfNewObject(obj, scrType);
|
asGetActiveContext()->GetEngine()->NotifyGarbageCollectorOfNewObject(obj, scrType);
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
PrimitiveArray(asUINT initialSize = 0) {
|
PrimitiveArray(asUINT initialSize = 0) {
|
||||||
inner.resize(initialSize);
|
inner.resize(initialSize);
|
||||||
}
|
}
|
||||||
PrimitiveArray(asUINT initialSize, T initialValue) {
|
PrimitiveArray(asUINT initialSize, T initialValue) {
|
||||||
inner.resize(initialSize, initialValue);
|
inner.resize(initialSize, initialValue);
|
||||||
}
|
}
|
||||||
PrimitiveArray(void *initList) {
|
PrimitiveArray(void *initList) {
|
||||||
asUINT length = *reinterpret_cast<const asUINT *>(initList);
|
asUINT length = *reinterpret_cast<const asUINT *>(initList);
|
||||||
inner.resize(length);
|
inner.resize(length);
|
||||||
memcpy(inner.data(), reinterpret_cast<const asUINT *>(initList) + 1, inner.size() * sizeof(T));
|
memcpy(inner.data(), reinterpret_cast<const asUINT *>(initList) + 1, inner.size() * sizeof(T));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddRef() {
|
void AddRef() {
|
||||||
refCount &= 0x7fffffff;
|
refCount &= 0x7fffffff;
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user