Merge branch 'master' of https://github.com/yvt/openspades
This commit is contained in:
commit
ab9ebacaef
@ -125,7 +125,8 @@ namespace spades {
|
|||||||
|
|
||||||
Client::Client(IRenderer *r, IAudioDevice *audioDev,
|
Client::Client(IRenderer *r, IAudioDevice *audioDev,
|
||||||
const ServerAddress& host, std::string playerName):
|
const ServerAddress& host, std::string playerName):
|
||||||
renderer(r), audioDevice(audioDev), playerName(playerName) {
|
renderer(r), audioDevice(audioDev), playerName(playerName) ,
|
||||||
|
hasDelayedReload(false) {
|
||||||
SPADES_MARK_FUNCTION();
|
SPADES_MARK_FUNCTION();
|
||||||
SPLog("Initializing...");
|
SPLog("Initializing...");
|
||||||
|
|
||||||
@ -635,6 +636,12 @@ namespace spades {
|
|||||||
// FIXME: send only there are any changed
|
// FIXME: send only there are any changed
|
||||||
net->SendPlayerInput(inp);
|
net->SendPlayerInput(inp);
|
||||||
net->SendWeaponInput(weapInput);
|
net->SendWeaponInput(weapInput);
|
||||||
|
|
||||||
|
if(hasDelayedReload) {
|
||||||
|
world->GetLocalPlayer()->Reload();
|
||||||
|
net->SendReload();
|
||||||
|
hasDelayedReload = false;
|
||||||
|
}
|
||||||
|
|
||||||
//PlayerInput actualInput = player->GetInput();
|
//PlayerInput actualInput = player->GetInput();
|
||||||
WeaponInput actualWeapInput = player->GetWeaponInput();
|
WeaponInput actualWeapInput = player->GetWeaponInput();
|
||||||
@ -842,6 +849,9 @@ namespace spades {
|
|||||||
// Well done!
|
// Well done!
|
||||||
renderer->FrameDone();
|
renderer->FrameDone();
|
||||||
renderer->Flip();
|
renderer->Flip();
|
||||||
|
|
||||||
|
// reset all "delayed actions" (in case we forget to reset these)
|
||||||
|
hasDelayedReload = false;
|
||||||
|
|
||||||
time += dt;
|
time += dt;
|
||||||
}
|
}
|
||||||
@ -1118,7 +1128,7 @@ namespace spades {
|
|||||||
weapInput.primary = down;
|
weapInput.primary = down;
|
||||||
}else if(CheckKey(cg_keyAltAttack, name)){
|
}else if(CheckKey(cg_keyAltAttack, name)){
|
||||||
if(world->GetLocalPlayer()->IsToolWeapon() && (!cg_holdAimDownSight)){
|
if(world->GetLocalPlayer()->IsToolWeapon() && (!cg_holdAimDownSight)){
|
||||||
if(down && !playerInput.sprint){
|
if(down && !playerInput.sprint && !world->GetLocalPlayer()->GetWeapon()->IsReloading()){
|
||||||
weapInput.secondary = !weapInput.secondary;
|
weapInput.secondary = !weapInput.secondary;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
@ -1135,10 +1145,17 @@ namespace spades {
|
|||||||
(!world->GetLocalPlayer()->IsAwaitingReloadCompletion()) &&
|
(!world->GetLocalPlayer()->IsAwaitingReloadCompletion()) &&
|
||||||
(!w->IsReloading()) &&
|
(!w->IsReloading()) &&
|
||||||
world->GetLocalPlayer()->GetTool() == Player::ToolWeapon){
|
world->GetLocalPlayer()->GetTool() == Player::ToolWeapon){
|
||||||
world->GetLocalPlayer()->Reload();
|
|
||||||
if(world->GetLocalPlayer()->IsToolWeapon()){
|
if(world->GetLocalPlayer()->IsToolWeapon()){
|
||||||
weapInput.secondary = false;
|
if(weapInput.secondary) {
|
||||||
|
// if we send WeaponInput after sending Reload,
|
||||||
|
// server might cancel the reload.
|
||||||
|
// https://github.com/infogulch/pyspades/blob/895879ed14ddee47bb278a77be86d62c7580f8b7/pyspades/server.py#343
|
||||||
|
hasDelayedReload = true;
|
||||||
|
weapInput.secondary = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
world->GetLocalPlayer()->Reload();
|
||||||
net->SendReload();
|
net->SendReload();
|
||||||
}
|
}
|
||||||
}else if(CheckKey(cg_keyToolSpade, name) && down){
|
}else if(CheckKey(cg_keyToolSpade, name) && down){
|
||||||
|
@ -128,6 +128,7 @@ namespace spades {
|
|||||||
float lastAliveTime;
|
float lastAliveTime;
|
||||||
int lastKills;
|
int lastKills;
|
||||||
float worldSetTime;
|
float worldSetTime;
|
||||||
|
bool hasDelayedReload;
|
||||||
struct HurtSprite {
|
struct HurtSprite {
|
||||||
float angle;
|
float angle;
|
||||||
float horzShift;
|
float horzShift;
|
||||||
|
@ -1278,6 +1278,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->ModeType() != IGameMode::m_TC ) {
|
if( mode->ModeType() != IGameMode::m_TC ) {
|
||||||
SPRaise("Received PacketTypeTerritoryCapture in non-TC gamemode");
|
SPRaise("Received PacketTypeTerritoryCapture in non-TC gamemode");
|
||||||
}
|
}
|
||||||
@ -1310,6 +1311,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->ModeType() != IGameMode::m_TC ) {
|
if( mode->ModeType() != IGameMode::m_TC ) {
|
||||||
SPRaise("Received PacketTypeProgressBar in non-TC gamemode");
|
SPRaise("Received PacketTypeProgressBar in non-TC gamemode");
|
||||||
}
|
}
|
||||||
@ -1335,6 +1337,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->ModeType() != IGameMode::m_CTF ) {
|
if( mode->ModeType() != IGameMode::m_CTF ) {
|
||||||
SPRaise("Received PacketTypeIntelCapture in non-TC gamemode");
|
SPRaise("Received PacketTypeIntelCapture in non-TC gamemode");
|
||||||
}
|
}
|
||||||
@ -1354,6 +1357,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->ModeType() != IGameMode::m_CTF ) {
|
if( mode->ModeType() != IGameMode::m_CTF ) {
|
||||||
SPRaise("Received PacketTypeIntelPickup in non-TC gamemode");
|
SPRaise("Received PacketTypeIntelPickup in non-TC gamemode");
|
||||||
}
|
}
|
||||||
@ -1368,6 +1372,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->ModeType() != IGameMode::m_CTF ) {
|
if( mode->ModeType() != IGameMode::m_CTF ) {
|
||||||
SPRaise("Received PacketTypeIntelPickup in non-TC gamemode");
|
SPRaise("Received PacketTypeIntelPickup in non-TC gamemode");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user