Skip to content
This repository has been archived by the owner on Dec 14, 2023. It is now read-only.

Commit

Permalink
Server limits + Add and clean up cvars
Browse files Browse the repository at this point in the history
TODO: make FOV limit not modify
  • Loading branch information
nonperforming committed Nov 15, 2022
1 parent c160a37 commit 55a5798
Show file tree
Hide file tree
Showing 11 changed files with 134 additions and 24 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,7 @@ Hides the server IP from cg_stats and sanitises player names (STUB)
### p_customClientMessage
Default: Nothing

Append text to your client info - anything you'd like. `p_showCustomClientMessage` has to be set to `1` for this variable to take effect

### p_showCustomClientMessage
Default: 0

See `p_customClientMessage`
Append text to your client info - anything you'd like.

### p_showAccuracyUnderMap
Default: 0
Expand All @@ -183,6 +178,11 @@ Default: 0

(STUB) Hides the block colo(u)r palette.

### p_fallingBlocks
Default: 0

Shows falling blocks

## Other
### !!IMPORTANT!!
Save files and game files are kept seperate from OpenSpades. This does not include mod `.pak`s or folders, though it is planned for OpenSpades+ to load mods from the folder `OSMods` instead which allows you to have OpenSpades+ specific mods. It is nigh impossible that OpenSpades+ will bork or even modify an OpenSpades install in any way. To use your OpenSpades config file as a template/your config file for OpenSpades+, you can copy your `SPConfig.cfg` over to `OSPlus.cfg` in the same folder. Please notice that OpenSpades+ uses different default options which you may find helpful. You can always set them manually however, see ["Useful console variables"](https://github.com/nonperforming/openspadesplus#useful-console-variables). There is a list of differences between OpenSpades+ and OpenSpades settings [here](https://github.com/nonperforming/openspadesplus/blob/main/info/diff.md)
Expand Down
2 changes: 1 addition & 1 deletion Resources/Scripts/Gui/Preferences.as
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,6 @@ namespace spades {

layouter.AddHeading(_Tr("Preferences", "OpenSpades+"));
layouter.AddToggleField(_Tr("Preferences", "Viewmodel"), "p_viewmodel");
layouter.AddToggleField(_Tr("Preferences", "Show Custom Client Message"), "p_showCustomClientMessage");
ConfigField @clientField = layouter.AddInputField(
_Tr("Preferences", "Custom Client Message"), "p_customClientMessage", not options.GameActive);
clientField.MaxLength = 100;
Expand All @@ -697,6 +696,7 @@ namespace spades {
layouter.AddToggleField(_Tr("Preferences", "Damage Blood"), "p_hurtBlood");
layouter.AddToggleField(_Tr("Preferences", "Corpses"), "p_corpse");
layouter.AddToggleField(_Tr("Preferences", "Palette"), "p_hidePalette");
layouter.AddToggleField(_Tr("Preferences", "Falling Blocks"), "p_fallingBlocks");

layouter.AddHeading(_Tr("Preferences", "PubOvl"));
layouter.AddToggleField(_Tr("Preferences", "Player names"), "po_names");
Expand Down
15 changes: 8 additions & 7 deletions Sources/Client/Client_Scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,16 @@ namespace spades {
def.time = (unsigned int)(time * 1000.f);
def.denyCameraBlur = true;
def.zFar = 200.f;

/* Delimit FOV
if (!((float)cg_fov < 90.0f)) {
cg_fov = 90.0f;

// Limit FOV according to server
if (!((float)cg_fov < Plus::maxFov)) {
// FOV too big
cg_fov = Plus::maxFov;
}
if (!((float)cg_fov > 45.0f)) {
cg_fov = 45.0f;
if (!((float)cg_fov > Plus::minFov)) {
// FOV too small
cg_fov = Plus::minFov;
}
*/

if (world) {
IntVector3 fogColor = world->GetFogColor();
Expand Down
8 changes: 7 additions & 1 deletion Sources/Client/FallingBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
#include <Core/Debug.h>
#include <Core/Exception.h>
#include <limits.h>
#include <Core/Settings.h>

SPADES_SETTING(p_fallingBlocks);

namespace spades {
namespace client {
Expand Down Expand Up @@ -174,7 +177,10 @@ namespace spades {
void FallingBlock::Render3D() {
ModelRenderParam param;
param.matrix = matrix;
// stubbed
if (Plus::HideBlocks || p_fallingBlocks)
{
client->GetRenderer().RenderModel(*model, param);
}
}
} // namespace client
} // namespace spades
26 changes: 26 additions & 0 deletions Sources/Client/NetClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#include <Core/TMPUtils.h>

DEFINE_SPADES_SETTING(cg_unicode, "1");
//SPADES_SETTING(cg_fov);

namespace spades {
namespace client {
Expand Down Expand Up @@ -92,6 +93,7 @@ namespace spades {
PacketTypeHandShakeReturn = 32, // C2S
PacketTypeVersionGet = 33, // S2C
PacketTypeVersionSend = 34, // C2S
PacketTypeOpenSpadesPlusSettings = 100
PacketTypeExtensionInfo = 60,

};
Expand Down Expand Up @@ -1115,6 +1117,20 @@ namespace spades {
client->PlayerCreatedBlock(*p);
}
} break;

// TODO: + OpenSpades+ Variable limits
case PacketTypeOpenSpadesPlusSettings:
{
SPLog("Setting server variable limits");
// FIXME: can we collapse this into one line?
Plus::minFov = reader.ReadInt();
Plus::maxFov = reader.ReadInt();
// TODO: Make FOV limit actually limit without modifying config
client->ServerSentMessage($"Server requested FOV limit be set to {0}-{0}", Plus::minFov, Plus::maxFov);
Plus::fallingBlocks = reader.ReadInt();
client->ServerSentMessage($"Server requested falling blocks display be set to {0}", Plus::fallingBlocks);
} break;

case PacketTypeStateData:
if (!GetWorld())
break;
Expand Down Expand Up @@ -1785,6 +1801,16 @@ namespace spades {
enet_peer_send(peer, 0, wri.CreatePacket());
}

/* Not needed here. See PacketTypeOpenSpadesPlusSettings packet handler
void NetClient::SendOpenSpadesPlusSettings()
{
SPADES_MARK_FUNCTION();
NetPacketWriter wri(PacketTypeOpenSpadesPlusSettings);
wri.Write((uint32_t)cg_fov); // FOV
//wri.Write();
SPLog("Sending OpenSpades+ settings.");
}*/

void NetClient::MapLoaded() {
SPADES_MARK_FUNCTION();

Expand Down
3 changes: 1 addition & 2 deletions Sources/Core/VersionInfo.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include <Core/Settings.h>
#include <Plus/OpenSpadesPlus.h>

SPADES_SETTING(p_showCustomClientMessage);
SPADES_SETTING(p_customClientMessage);

#if __linux__
Expand Down Expand Up @@ -69,7 +68,7 @@ std::string VersionInfo::GetVersionInfo() {
buffer += " | OpenSpades+ Revision ";
buffer += std::to_string(spades::plus::revision);

if (p_showCustomClientMessage)
if (p_customClientMessage != "")
{
std::string message = p_customClientMessage;

Expand Down
11 changes: 7 additions & 4 deletions Sources/Plus/OpenSpadesPlus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,23 @@
#include <Core/Settings.h>

DEFINE_SPADES_SETTING(p_viewmodel, "0");
DEFINE_SPADES_SETTING(p_showCustomClientMessage, "0");
DEFINE_SPADES_SETTING(p_customClientMessage, "");
DEFINE_SPADES_SETTING(p_showIP, "1");
DEFINE_SPADES_SETTING(p_showAccuracyInStats, "1");
DEFINE_SPADES_SETTING(p_showAccuracyUnderMap, "0");
DEFINE_SPADES_SETTING(p_streamer, "0");
DEFINE_SPADES_SETTING(p_corpse, "0");
DEFINE_SPADES_SETTING(p_hidePalette, "0");
DEFINE_SPADES_SETTING(p_fallingBlocks, "0");

DEFINE_SPADES_SETTING(p_hurtTint, "1");
DEFINE_SPADES_SETTING(p_hurtBlood, "0");

namespace spades {
namespace plus {
const int revision = 12;
namespace spades
{
namespace plus
{
const int revision = 12;

} // namespace client
} // namespace spades
6 changes: 4 additions & 2 deletions Sources/Plus/OpenSpadesPlus.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@

#pragma once

namespace spades {
namespace plus {
namespace spades
{
namespace plus
{
extern const int revision;
} // namespace client
} // namespace spades
41 changes: 41 additions & 0 deletions Sources/Plus/ServerLimits.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
Copyright (c) 2022 non_performing
This file is part of OpenSpades+.
OpenSpades+ is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenSpades+ is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenSpades+. If not, see <http://www.gnu.org/licenses/>.
*/

#include "ServerLimits.h"
#include <iostream>
#include <Core/Settings.h>

namespace spades
{
namespace plus
{
float minFov = -360;
float maxFov = 360;
int fallingBlocks = 1;

void resetLimits()
{
minFov = -360;
maxFov = 360;
fallingBlocks = 1;
}
}
}
33 changes: 33 additions & 0 deletions Sources/Plus/ServerLimits.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
Copyright (c) 2022 non_performing
This file is part of OpenSpades+.
OpenSpades+ is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenSpades+ is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenSpades+. If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

namespace spades
{
namespace plus
{
//extern float trueFov;
extern float minFov;
extern float maxFov;
extern int fallingBlocks;
}
}
1 change: 0 additions & 1 deletion info/diff.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ p_hurtBlood: 0 <
p_hurtTint: 1 <
p_showAccuracyInStats: 1 <
p_showAccuracyUnderMap: 0 <
p_showCustomClientMessage: 0 <
p_showIP: 1 <
p_streamer: 0 <
p_viewmodel: 0 <
Expand Down

0 comments on commit 55a5798

Please sign in to comment.