parent
aa22e4b25a
commit
a853a58631
@ -295,6 +295,7 @@
|
||||
E89A5F1E1DF8732200857F65 /* ShellApi.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E89A5F1C1DF8732200857F65 /* ShellApi.cpp */; };
|
||||
E89A5F201DF8759200857F65 /* ShellApi.mm in Sources */ = {isa = PBXBuildFile; fileRef = E89A5F1F1DF8759200857F65 /* ShellApi.mm */; };
|
||||
E89BBDC31B3559CD00F53EE9 /* GLAutoExposureFilter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E89BBDC01B3559CD00F53EE9 /* GLAutoExposureFilter.cpp */; };
|
||||
E8A2EBA01F5BE16D00E39CD9 /* GameProperties.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E8A2EB9E1F5BE16D00E39CD9 /* GameProperties.cpp */; };
|
||||
E8CB47CE1DE071CA00BF606A /* SWUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E8CB47CC1DE071CA00BF606A /* SWUtils.cpp */; };
|
||||
E8CB47D21DE07CF000BF606A /* SettingSet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E8CB47CF1DE07CF000BF606A /* SettingSet.cpp */; };
|
||||
E8CB47D61DE084AB00BF606A /* GLSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E8CB47D41DE084AB00BF606A /* GLSettings.cpp */; };
|
||||
@ -597,6 +598,8 @@
|
||||
E89BBDC11B3559CD00F53EE9 /* GLAutoExposureFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GLAutoExposureFilter.h; sourceTree = "<group>"; };
|
||||
E89E811F179C2C800059C649 /* GLBloomFilter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GLBloomFilter.cpp; sourceTree = "<group>"; };
|
||||
E89E8120179C2C800059C649 /* GLBloomFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GLBloomFilter.h; sourceTree = "<group>"; };
|
||||
E8A2EB9E1F5BE16D00E39CD9 /* GameProperties.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GameProperties.cpp; sourceTree = "<group>"; };
|
||||
E8A2EB9F1F5BE16D00E39CD9 /* GameProperties.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GameProperties.h; sourceTree = "<group>"; };
|
||||
E8B6B63F17DE27B500E35523 /* angelscript.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = angelscript.h; sourceTree = "<group>"; };
|
||||
E8B6B64117DE27B500E35523 /* as_array.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = as_array.h; sourceTree = "<group>"; };
|
||||
E8B6B64217DE27B500E35523 /* as_atomic.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = as_atomic.cpp; sourceTree = "<group>"; };
|
||||
@ -1654,6 +1657,8 @@
|
||||
E88318E517928EAC002ABE6D /* PhysicsConstants.h */,
|
||||
E8FE748818CB329C00291338 /* HitTestDebugger.cpp */,
|
||||
E8FE748918CB329C00291338 /* HitTestDebugger.h */,
|
||||
E8A2EB9E1F5BE16D00E39CD9 /* GameProperties.cpp */,
|
||||
E8A2EB9F1F5BE16D00E39CD9 /* GameProperties.h */,
|
||||
);
|
||||
name = World;
|
||||
sourceTree = "<group>";
|
||||
@ -2011,6 +2016,7 @@
|
||||
E82E67EA18EA7A51004DBA18 /* packet.c in Sources */,
|
||||
E82E67EB18EA7A51004DBA18 /* peer.c in Sources */,
|
||||
E81012311E1D7301009955D3 /* Icon.cpp in Sources */,
|
||||
E8A2EBA01F5BE16D00E39CD9 /* GameProperties.cpp in Sources */,
|
||||
E82E67EC18EA7A51004DBA18 /* protocol.c in Sources */,
|
||||
E82E67ED18EA7A51004DBA18 /* unix.c in Sources */,
|
||||
E82E67EE18EA7A51004DBA18 /* win32.c in Sources */,
|
||||
|
@ -235,6 +235,7 @@ namespace spades {
|
||||
void RemoveAllCorpses();
|
||||
void RemoveInvisibleCorpses();
|
||||
void RemoveAllLocalEntities();
|
||||
void RemoveCorpseForPlayer(int playerId);
|
||||
|
||||
int nextScreenShotIndex;
|
||||
int nextMapShotIndex;
|
||||
@ -337,6 +338,7 @@ namespace spades {
|
||||
void GrenadeDestroyedBlock(IntVector3);
|
||||
void PlayerLeaving(Player *);
|
||||
void PlayerJoinedTeam(Player *);
|
||||
void PlayerSpawned(Player *);
|
||||
|
||||
virtual void PlayerObjectSet(int);
|
||||
virtual void PlayerMadeFootstep(Player *);
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
#include <iterator>
|
||||
|
||||
#include "Client.h"
|
||||
|
||||
@ -98,6 +99,18 @@ namespace spades {
|
||||
corpses.erase(its[i]);
|
||||
}
|
||||
|
||||
void Client::RemoveCorpseForPlayer(int playerId) {
|
||||
for (auto it = corpses.begin(); it != corpses.end();) {
|
||||
auto cur = it;
|
||||
++it;
|
||||
|
||||
auto &c = *cur;
|
||||
if (c->GetPlayerId() == playerId) {
|
||||
corpses.erase(cur);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Player *Client::HotTrackedPlayer(hitTag_t *hitFlag) {
|
||||
if (!world)
|
||||
return nullptr;
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "IGameMode.h"
|
||||
#include "TCGameMode.h"
|
||||
#include "World.h"
|
||||
#include "GameProperties.h"
|
||||
|
||||
#include "CenterMessageView.h"
|
||||
#include "ChatWindow.h"
|
||||
@ -249,6 +250,7 @@ namespace spades {
|
||||
scriptedUI->RecordChatLog(
|
||||
msg, MakeVector4(col.x / 255.f, col.y / 255.f, col.z / 255.f, 0.8f));
|
||||
}
|
||||
RemoveCorpseForPlayer(p->GetId());
|
||||
}
|
||||
|
||||
void Client::PlayerJoinedTeam(spades::client::Player *p) {
|
||||
@ -277,6 +279,12 @@ namespace spades {
|
||||
}
|
||||
}
|
||||
|
||||
void Client::PlayerSpawned(Player *p) {
|
||||
if (net->GetGameProperties()->clearCorpseOnRespawn) {
|
||||
RemoveCorpseForPlayer(p->GetId());
|
||||
}
|
||||
}
|
||||
|
||||
void Client::GrenadeDestroyedBlock(spades::IntVector3 blk) {
|
||||
for (int x = blk.x - 1; x <= blk.x + 1; x++)
|
||||
for (int y = blk.y - 1; y <= blk.y + 1; y++)
|
||||
|
@ -37,6 +37,8 @@ namespace spades {
|
||||
: renderer(renderer), map(map) {
|
||||
SPADES_MARK_FUNCTION();
|
||||
|
||||
playerId = p->GetId();
|
||||
|
||||
IntVector3 col = p->GetWorld()->GetTeam(p->GetTeamId()).color;
|
||||
color = MakeVector3(col.x / 255.f, col.y / 255.f, col.z / 255.f);
|
||||
|
||||
|
@ -64,6 +64,7 @@ namespace spades {
|
||||
IRenderer *renderer;
|
||||
GameMap *map;
|
||||
Vector3 color;
|
||||
int playerId;
|
||||
|
||||
Node nodes[NodeCount];
|
||||
Edge edges[8];
|
||||
@ -89,6 +90,8 @@ namespace spades {
|
||||
|
||||
void Update(float dt);
|
||||
|
||||
int GetPlayerId() { return playerId; }
|
||||
|
||||
void AddToScene();
|
||||
|
||||
Vector3 GetCenter();
|
||||
|
36
Sources/Client/GameProperties.cpp
Normal file
36
Sources/Client/GameProperties.cpp
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
Copyright (c) 2017 yvt
|
||||
|
||||
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 "GameProperties.h"
|
||||
#include <Core/Debug.h>
|
||||
|
||||
namespace spades {
|
||||
namespace client {
|
||||
void GameProperties::HandleServerMessage(const std::string &msg) {
|
||||
if (!useHeuristics) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (msg == "Game mode: Arena by Yourself") {
|
||||
clearCorpseOnRespawn = true;
|
||||
SPLog("Enabled clearCorpseOnRespawn based on a server message heuristics");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
54
Sources/Client/GameProperties.h
Normal file
54
Sources/Client/GameProperties.h
Normal file
@ -0,0 +1,54 @@
|
||||
/*
|
||||
Copyright (c) 2017 yvt
|
||||
|
||||
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
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <Core/ServerAddress.h>
|
||||
|
||||
namespace spades {
|
||||
namespace client {
|
||||
/**
|
||||
* Stores properties that affect the gameplay.
|
||||
*/
|
||||
struct GameProperties {
|
||||
/**
|
||||
* Construct and initialize `GameProperties` with values optimal for the compatibility
|
||||
* with the original client.
|
||||
*/
|
||||
GameProperties() {}
|
||||
|
||||
/**
|
||||
* Parse a given server message and speculatively update the properties.
|
||||
*/
|
||||
void HandleServerMessage(const std::string &msg);
|
||||
|
||||
/**
|
||||
* Indicates whether the server does not provide the game properties in a way OpenSpades
|
||||
* can reliably parse and it must speculate them using non-program friendly information
|
||||
* (e.g., server message).
|
||||
*/
|
||||
bool useHeuristics = true;
|
||||
|
||||
bool clearCorpseOnRespawn = false;
|
||||
};
|
||||
}
|
||||
}
|
@ -33,6 +33,7 @@
|
||||
#include "Player.h"
|
||||
#include "TCGameMode.h"
|
||||
#include "World.h"
|
||||
#include "GameProperties.h"
|
||||
#include <Core/CP437.h>
|
||||
#include <Core/Debug.h>
|
||||
#include <Core/Debug.h>
|
||||
@ -378,6 +379,8 @@ namespace spades {
|
||||
|
||||
std::fill(savedPlayerTeam.begin(), savedPlayerTeam.end(), -1);
|
||||
|
||||
properties.reset(new GameProperties());
|
||||
|
||||
bandwidthMonitor.reset(new BandwidthMonitor(host));
|
||||
}
|
||||
NetClient::~NetClient() {
|
||||
@ -1038,6 +1041,7 @@ namespace spades {
|
||||
savedPlayerTeam[pId] = team;
|
||||
}
|
||||
}
|
||||
client->PlayerSpawned(p);
|
||||
|
||||
} break;
|
||||
case PacketTypeBlockAction: {
|
||||
@ -1262,11 +1266,13 @@ namespace spades {
|
||||
break;
|
||||
case 2: // system???
|
||||
client->ServerSentMessage(txt);
|
||||
/*SPRaise("Player #%d %s sent system message", p->GetId(),
|
||||
* p->GetName().c_str());*/
|
||||
}
|
||||
} else {
|
||||
client->ServerSentMessage(txt);
|
||||
|
||||
// Speculate the best game properties based on the server generated
|
||||
// messages
|
||||
properties->HandleServerMessage(txt);
|
||||
}
|
||||
} break;
|
||||
case PacketTypeMapStart: {
|
||||
|
@ -56,6 +56,7 @@ namespace spades {
|
||||
struct PlayerInput;
|
||||
struct WeaponInput;
|
||||
class Grenade;
|
||||
class GameProperties;
|
||||
class NetClient {
|
||||
Client *client;
|
||||
NetClientStatus status;
|
||||
@ -64,6 +65,7 @@ namespace spades {
|
||||
std::string statusString;
|
||||
unsigned int mapSize;
|
||||
std::vector<char> mapData;
|
||||
std::shared_ptr<GameProperties> properties;
|
||||
|
||||
int protocolVersion;
|
||||
|
||||
@ -129,6 +131,11 @@ namespace spades {
|
||||
|
||||
std::string GetStatusString() { return statusString; }
|
||||
|
||||
/**
|
||||
* Return a non-null reference to `GameProperties` for this connection.
|
||||
*/
|
||||
std::shared_ptr<GameProperties>& GetGameProperties() { return properties; }
|
||||
|
||||
void Connect(const ServerAddress &hostname);
|
||||
void Disconnect();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user