From a8f7098445167e518993d7b2b54c7f280f3b746a Mon Sep 17 00:00:00 2001 From: Andy Kernel <171799466+starswaitforus@users.noreply.github.com> Date: Tue, 20 Aug 2024 19:40:22 +0200 Subject: [PATCH] Small touches --- server/src/Map/DefaultMap.php | 5 ++ .../src/Net/Protocol/BinaryProtocol.php.txt | 79 ------------------- server/src/Traits/Player/AttackTrait.php | 3 +- www/assets/js/Hud.js | 2 +- 4 files changed, 7 insertions(+), 82 deletions(-) delete mode 100644 server/src/Net/Protocol/BinaryProtocol.php.txt diff --git a/server/src/Map/DefaultMap.php b/server/src/Map/DefaultMap.php index 15a4bbb..f182c53 100644 --- a/server/src/Map/DefaultMap.php +++ b/server/src/Map/DefaultMap.php @@ -76,6 +76,11 @@ public function getSpawnRotationDefender(): int return 180; } + public function getBombMaxBlastDistance(): int + { + return 1500; + } + public function getBuyArea(bool $forAttackers): Box { return $this->buyArea[(int)$forAttackers]; diff --git a/server/src/Net/Protocol/BinaryProtocol.php.txt b/server/src/Net/Protocol/BinaryProtocol.php.txt deleted file mode 100644 index ae569f8..0000000 --- a/server/src/Net/Protocol/BinaryProtocol.php.txt +++ /dev/null @@ -1,79 +0,0 @@ -/* -namespace cs\Net\Protocol; - -use cs\Core\Game; -use cs\Core\GameException; -use cs\Net\Protocol; -use cs\Net\ProtocolException; -use cs\Net\ServerSetting; - -class BinaryProtocol extends Protocol -{ - - // Params are always unsigned int with little endian byte order - public const UINT_8 = 'C'; - public const UINT_16 = 'v'; - //public const UINT_32 = 'V'; - - const TYPE_GAMEPLAY = "\x00"; - const TYPE_GAME = "\x01"; - const METHOD_SEPARATOR = "\xFF"; - - const RESPONSE_EVENT = "\x00"; - const RESPONSE_ERROR = "\x01"; - - /** @var array [methodName => [param1type, param2type] */ - public const methodMap = [ - 'duck' => [self::UINT_8], - 'equip' => [self::UINT_8], - 'jump' => [], - 'move' => [self::UINT_8], - 'look' => [self::UINT_16, self::UINT_16], - ]; - /** @var array */ - public const paramLengthBytes = [ - self::UINT_8 => 1, - self::UINT_16 => 2, - ]; - - public function parsePlayerControlCommands(string $msg): array - { - $commands = []; - foreach (explode(self::METHOD_SEPARATOR, $msg) as $line) { - $command = []; - $offset = 0; - - $format = self::UINT_8; - $methodNumber = $this->parseInt($line, $format, $offset); - $offset += self::paramLengthBytes[$format]; - $method = self::playerMethodByNumber[$methodNumber]; - $command[] = $method; - - $params = self::methodMap[$method]; - if (isset($params[0])) { - $format = $params[0]; - $command[] = $this->parseInt($line, $format, $offset); - $offset += self::paramLengthBytes[$format]; - } - if (isset($params[1])) { - $format = $params[1]; - $command[] = $this->parseInt($line, $format, $offset); - $offset += self::paramLengthBytes[$format]; - } - - $commands[] = $command; - } - - return $commands; - } - - private function parseInt(string $binary, string $unpackFormat, int $binaryOffset): int - { - $data = @unpack($unpackFormat, substr($binary, $binaryOffset, self::paramLengthBytes[$unpackFormat])); - if ($data === false) { - throw new ProtocolException("Parse error: " . bin2hex($binary)); - } - return (int)$data[1]; - } - -} diff --git a/server/src/Traits/Player/AttackTrait.php b/server/src/Traits/Player/AttackTrait.php index baa8126..ebc6ee8 100644 --- a/server/src/Traits/Player/AttackTrait.php +++ b/server/src/Traits/Player/AttackTrait.php @@ -97,8 +97,7 @@ private function getThrowSpeed(): int protected function createAttackEvent(AttackEnable $item): Attackable { - $origin = $this->getPositionClone(); - $origin->addY($this->getSightHeight()); + $origin = $this->getSightPositionClone(); if ($item instanceof Grenade) { $event = new ThrowEvent( diff --git a/www/assets/js/Hud.js b/www/assets/js/Hud.js index 33d9fcc..7342f1c 100644 --- a/www/assets/js/Hud.js +++ b/www/assets/js/Hud.js @@ -297,7 +297,7 @@ export class HUD {
0 $ 🛒
- +