Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/Const/Commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,23 +209,23 @@ export const commandCallbacks = {
game_set_level: (client: Client, levelArg: string) => {
const level = parseInt(levelArg);
const player = client.camera?.cameraData.player;
if (isNaN(level) || !Entity.exists(player) || !TankBody.isTank(player)) return;
if (!isFinite(level) || !Entity.exists(player) || !TankBody.isTank(player)) return;
const finalLevel = client.accessLevel == AccessLevel.FullAccess ? level : Math.min(maxPlayerLevel, level);
client.camera?.setLevel(finalLevel);
},
game_set_score: (client: Client, scoreArg: string) => {
const score = parseInt(scoreArg);
const camera = client.camera?.cameraData;
const player = client.camera?.cameraData.player;
if (isNaN(score) || score > Number.MAX_SAFE_INTEGER || score < Number.MIN_SAFE_INTEGER || !Entity.exists(player) || !TankBody.isTank(player) || !camera) return;
if (!isFinite(score) || score > Number.MAX_SAFE_INTEGER || score < Number.MIN_SAFE_INTEGER || !Entity.exists(player) || !TankBody.isTank(player) || !camera) return;
camera.score = score;
},
game_set_stat_max: (client: Client, statIdArg: string, statMaxArg: string) => {
const statId = StatCount - parseInt(statIdArg);
const statMax = parseInt(statMaxArg);
const camera = client.camera?.cameraData;
const player = client.camera?.cameraData.player;
if (statId < 0 || statId >= StatCount || isNaN(statId) || isNaN(statMax) || !Entity.exists(player) || !TankBody.isTank(player) || !camera) return;
if (statId < 0 || statId >= StatCount || !isFinite(statId) || !isFinite(statMax) || !Entity.exists(player) || !TankBody.isTank(player) || !camera) return;
const clampedStatMax = Math.max(statMax, 0);
camera.statLimits[statId as Stat] = clampedStatMax;
camera.statLevels[statId as Stat] = Math.min(camera.statLevels[statId as Stat], clampedStatMax);
Expand All @@ -235,14 +235,14 @@ export const commandCallbacks = {
const statPoints = parseInt(statPointsArg);
const camera = client.camera?.cameraData;
const player = client.camera?.cameraData.player;
if (statId < 0 || statId >= StatCount || isNaN(statId) || isNaN(statPoints) || !Entity.exists(player) || !TankBody.isTank(player) || !camera) return;
if (statId < 0 || statId >= StatCount || !isFinite(statId) || !isFinite(statPoints) || !Entity.exists(player) || !TankBody.isTank(player) || !camera) return;
camera.statLevels[statId as Stat] = statPoints;
},
game_add_upgrade_points: (client: Client, pointsArg: string) => {
const points = parseInt(pointsArg);
const camera = client.camera?.cameraData;
const player = client.camera?.cameraData.player;
if (isNaN(points) || points > Number.MAX_SAFE_INTEGER || points < Number.MIN_SAFE_INTEGER || !Entity.exists(player) || !TankBody.isTank(player) || !camera) return;
if (!isFinite(points) || points > Number.MAX_SAFE_INTEGER || points < Number.MIN_SAFE_INTEGER || !Entity.exists(player) || !TankBody.isTank(player) || !camera) return;
camera.statsAvailable += points;
},
game_teleport: (client: Client, xArg: string, yArg: string) => {
Expand All @@ -254,7 +254,7 @@ export const commandCallbacks = {
const x = xArg.match(RELATIVE_POS_REGEX) ? player.positionData.x + parseInt(xArg.slice(1) || "0", 10) : parseInt(xArg, 10);
const y = yArg.match(RELATIVE_POS_REGEX) ? player.positionData.y + parseInt(yArg.slice(1) || "0", 10) : parseInt(yArg, 10);

if (isNaN(x) || isNaN(y)) return;
if (!isFinite(x) || !isFinite(y)) return;

player.positionData.x = x;
player.positionData.y = y;
Expand Down Expand Up @@ -355,11 +355,11 @@ export const commandCallbacks = {
["Triangle", Triangle]
] as [string, typeof ObjectEntity][]).get(entityArg);

if (isNaN(count) || count < 0 || !game || !TEntity) return;
if (!isFinite(count) || count < 0 || !game || !TEntity) return;

for (let i = 0; i < count; ++i) {
const boss = new TEntity(game);
if (!isNaN(x) && !isNaN(y)) {
if (isFinite(x) && isFinite(y)) {
boss.positionData.x = x;
boss.positionData.y = y;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Entity/Object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import * as util from "../util";
import GameServer from "../Game";
import Vector, { VectorAbstract } from "../Physics/Vector";
import Vector from "../Physics/Vector";

import { PhysicsGroup, PositionGroup, RelationsGroup, StyleGroup } from "../Native/FieldGroups";
import { Entity } from "../Native/Entity";
Expand Down
2 changes: 1 addition & 1 deletion src/Entity/Tank/Barrel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export default class Barrel extends ObjectEntity {
/** Number of drones that this barrel shot that are still alive. */
public droneCount = 0;

/** The barrel"s addons */
/** The barrel's addons */
public addons: BarrelAddon[] = [];

/** Always existant barrel field group, present on all barrels. */
Expand Down
4 changes: 3 additions & 1 deletion src/Gamemodes/Domination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import Client from "../Client";
import { Color, ColorsHexCode, ArenaFlags, ValidScoreboardIndex, ClientBound } from "../Const/Enums";
import ObjectEntity from "../Entity/Object";
import Dominator from "../Entity/Misc/Dominator";
import TeamBase from "../Entity/Misc/TeamBase";
import { TeamEntity } from "../Entity/Misc/TeamEntity";
Expand Down Expand Up @@ -94,6 +93,9 @@ export default class DominationArena extends ArenaEntity {
const team = this.decideTeam(client);
TeamEntity.setTeam(team, tank);

const success = this.attemptFactorySpawn(tank);
if (success) return;

const teamBase = team.base;
if (!teamBase) return super.spawnPlayer(tank, client);

Expand Down
2 changes: 1 addition & 1 deletion src/Gamemodes/Survival.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import TankBody from "../Entity/Tank/TankBody";

import ShapeManager from "../Misc/ShapeManager";
import { ArenaFlags, ClientBound } from "../Const/Enums";
import { tps, countdownDuration, scoreboardUpdateInterval } from "../config";
import { countdownDuration, scoreboardUpdateInterval } from "../config";

const MIN_PLAYERS = 4; // 6 in Diep.io

Expand Down
1 change: 0 additions & 1 deletion src/Gamemodes/Team2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import GameServer from "../Game";
import ArenaEntity from "../Native/Arena";
import Client from "../Client";

import ObjectEntity from "../Entity/Object";
import TeamBase from "../Entity/Misc/TeamBase";
import TankBody from "../Entity/Tank/TankBody";

Expand Down
1 change: 0 additions & 1 deletion src/Gamemodes/Team4.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import GameServer from "../Game";
import ArenaEntity from "../Native/Arena";
import Client from "../Client";

import ObjectEntity from "../Entity/Object";
import TeamBase from "../Entity/Misc/TeamBase";
import TankBody from "../Entity/Tank/TankBody";

Expand Down
2 changes: 1 addition & 1 deletion src/Native/Arena.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { TeamEntity, TeamGroupEntity } from "../Entity/Misc/TeamEntity";

import Client from "../Client";

import { countdownDuration, bossSpawningInterval, factorySpawnChance, scoreboardUpdateInterval } from "../config";
import { countdownDuration, factorySpawnChance, scoreboardUpdateInterval } from "../config";

export const enum ArenaState {
/** Countdown, waiting for players screen */
Expand Down