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,
|
||||
const ServerAddress& host, std::string playerName):
|
||||
renderer(r), audioDevice(audioDev), playerName(playerName) {
|
||||
renderer(r), audioDevice(audioDev), playerName(playerName) ,
|
||||
hasDelayedReload(false) {
|
||||
SPADES_MARK_FUNCTION();
|
||||
SPLog("Initializing...");
|
||||
|
||||
@ -635,6 +636,12 @@ namespace spades {
|
||||
// FIXME: send only there are any changed
|
||||
net->SendPlayerInput(inp);
|
||||
net->SendWeaponInput(weapInput);
|
||||
|
||||
if(hasDelayedReload) {
|
||||
world->GetLocalPlayer()->Reload();
|
||||
net->SendReload();
|
||||
hasDelayedReload = false;
|
||||
}
|
||||
|
||||
//PlayerInput actualInput = player->GetInput();
|
||||
WeaponInput actualWeapInput = player->GetWeaponInput();
|
||||
@ -842,6 +849,9 @@ namespace spades {
|
||||
// Well done!
|
||||
renderer->FrameDone();
|
||||
renderer->Flip();
|
||||
|
||||
// reset all "delayed actions" (in case we forget to reset these)
|
||||
hasDelayedReload = false;
|
||||
|
||||
time += dt;
|
||||
}
|
||||
@ -1118,7 +1128,7 @@ namespace spades {
|
||||
weapInput.primary = down;
|
||||
}else if(CheckKey(cg_keyAltAttack, name)){
|
||||
if(world->GetLocalPlayer()->IsToolWeapon() && (!cg_holdAimDownSight)){
|
||||
if(down && !playerInput.sprint){
|
||||
if(down && !playerInput.sprint && !world->GetLocalPlayer()->GetWeapon()->IsReloading()){
|
||||
weapInput.secondary = !weapInput.secondary;
|
||||
}
|
||||
}else{
|
||||
@ -1135,10 +1145,17 @@ namespace spades {
|
||||
(!world->GetLocalPlayer()->IsAwaitingReloadCompletion()) &&
|
||||
(!w->IsReloading()) &&
|
||||
world->GetLocalPlayer()->GetTool() == Player::ToolWeapon){
|
||||
world->GetLocalPlayer()->Reload();
|
||||
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();
|
||||
}
|
||||
}else if(CheckKey(cg_keyToolSpade, name) && down){
|
||||
|
@ -128,6 +128,7 @@ namespace spades {
|
||||
float lastAliveTime;
|
||||
int lastKills;
|
||||
float worldSetTime;
|
||||
bool hasDelayedReload;
|
||||
struct HurtSprite {
|
||||
float angle;
|
||||
float horzShift;
|
||||
|
@ -1278,6 +1278,7 @@ namespace spades {
|
||||
int state = reader.ReadByte();
|
||||
|
||||
IGameMode* mode = GetWorld()->GetMode();
|
||||
if(mode == NULL) break;
|
||||
if( mode->ModeType() != IGameMode::m_TC ) {
|
||||
SPRaise("Received PacketTypeTerritoryCapture in non-TC gamemode");
|
||||
}
|
||||
@ -1310,6 +1311,7 @@ namespace spades {
|
||||
float progress = reader.ReadFloat();
|
||||
|
||||
IGameMode* mode = GetWorld()->GetMode();
|
||||
if(mode == NULL) break;
|
||||
if( mode->ModeType() != IGameMode::m_TC ) {
|
||||
SPRaise("Received PacketTypeProgressBar in non-TC gamemode");
|
||||
}
|
||||
@ -1335,6 +1337,7 @@ namespace spades {
|
||||
{
|
||||
if(!GetWorld()) SPRaise("No world");
|
||||
IGameMode* mode = GetWorld()->GetMode();
|
||||
if(mode == NULL) break;
|
||||
if( mode->ModeType() != IGameMode::m_CTF ) {
|
||||
SPRaise("Received PacketTypeIntelCapture in non-TC gamemode");
|
||||
}
|
||||
@ -1354,6 +1357,7 @@ namespace spades {
|
||||
{
|
||||
Player *p = GetPlayer(reader.ReadByte());
|
||||
IGameMode* mode = GetWorld()->GetMode();
|
||||
if(mode == NULL) break;
|
||||
if( mode->ModeType() != IGameMode::m_CTF ) {
|
||||
SPRaise("Received PacketTypeIntelPickup in non-TC gamemode");
|
||||
}
|
||||
@ -1368,6 +1372,7 @@ namespace spades {
|
||||
{
|
||||
Player *p = GetPlayer(reader.ReadByte());
|
||||
IGameMode* mode = GetWorld()->GetMode();
|
||||
if(mode == NULL) break;
|
||||
if( mode->ModeType() != IGameMode::m_CTF ) {
|
||||
SPRaise("Received PacketTypeIntelPickup in non-TC gamemode");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user