Small touches

This commit is contained in:
Andy Kernel 2024-08-20 19:40:22 +02:00 committed by solcloud
parent b380e97426
commit a8f7098445
4 changed files with 7 additions and 82 deletions

View File

@ -76,6 +76,11 @@ class DefaultMap extends BoxMap
return 180;
}
public function getBombMaxBlastDistance(): int
{
return 1500;
}
public function getBuyArea(bool $forAttackers): Box
{
return $this->buyArea[(int)$forAttackers];

View File

@ -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<string,string[]> [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<string,int> */
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];
}
}

View File

@ -97,8 +97,7 @@ trait AttackTrait
protected function createAttackEvent(AttackEnable $item): Attackable
{
$origin = $this->getPositionClone();
$origin->addY($this->getSightHeight());
$origin = $this->getSightPositionClone();
if ($item instanceof Grenade) {
$event = new ThrowEvent(

View File

@ -297,7 +297,7 @@ export class HUD {
<canvas id="radar-canvas"></canvas>
</div>
<div class="money bg"><span data-money>0</span> $ <span data-can-buy>🛒</span></div>
<div data-have-bomb class="hidden icons" style="margin:22px 4px;font-size:200%;color:#fdf46e"><span data-can-plant class="hidden">🠻&nbsp;</span>\uE031</div>
<div data-have-bomb class="hidden icons" style="margin:22px 4px;font-size:200%;color:#fdf46e"><span data-can-plant class="hidden">&nbsp;</span>\uE031</div>
<div data-have-defuse-kit class="hidden icons" style="margin:22px 4px;font-size:200%;color:#5d8dea">\uE066</div>
</div>
<div class="bottom">