Skip to content

Commit

Permalink
turns out this would conflict with some scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
siecvi committed Sep 22, 2024
1 parent cde3e55 commit 29fa05d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 19 deletions.
13 changes: 3 additions & 10 deletions Sources/Client/NetClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -846,19 +846,12 @@ namespace spades {
if (!GetWorld())
break;
{
Player& p = GetPlayer(r.ReadByte());
int pId = r.ReadByte(); // skip player Id
float fuse = r.ReadFloat();
Vector3 pos = r.ReadVector3();
Vector3 vel = r.ReadVector3();

if (p.IsLocalPlayer()) {
break;
} else {
Grenade* g = new Grenade(*GetWorld(), pos, vel, fuse);

p.ThrowGrenade();
GetWorld()->AddGrenade(std::unique_ptr<Grenade>{g});
}
Grenade* g = new Grenade(*GetWorld(), pos, vel, fuse);
GetWorld()->AddGrenade(std::unique_ptr<Grenade>{g});
}
break;
case PacketTypeSetTool: {
Expand Down
15 changes: 8 additions & 7 deletions Sources/Client/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,15 +449,16 @@ namespace spades {
} else if (tool == ToolBlock) {
if (weapInput.primary && world.GetTime() > nextBlockTime)
nextBlockTime = world.GetTime() + primaryDelay;
} else if (tool == ToolGrenade && isLocal) {
} else if (tool == ToolGrenade) {
if (GetGrenadeCookTime() >= 3.0F)
ThrowGrenade();
} else if (tool == ToolGrenade) {
if (weapInput.primary) {
CookGrenade();
} else {
// grenade throw is sent by the server
cookingGrenade = false;

if (!isLocal) {
if (weapInput.primary) {
CookGrenade();
} else {
ThrowGrenade();
}
}
} else if (tool == ToolWeapon && !isLocal) {
weapon->SetShooting(weapInput.primary);
Expand Down
5 changes: 3 additions & 2 deletions Sources/Client/Player.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ namespace spades {
void UseSpade(bool dig);
void FireWeapon();

void CookGrenade();
void ThrowGrenade();

public:
Player(World&, int pId, WeaponType wType,
int tId, Vector3 pos, IntVector3 col);
Expand Down Expand Up @@ -181,8 +184,6 @@ namespace spades {
void Restock();
void GotBlock() { blockStocks = std::min(blockStocks + 1, 50); }
void UseBlocks(int c) { blockStocks = std::max(blockStocks - c, 0); }
void CookGrenade();
void ThrowGrenade();

bool IsToolSpade() { return tool == ToolSpade; }
bool IsToolBlock() { return tool == ToolBlock; }
Expand Down

0 comments on commit 29fa05d

Please sign in to comment.