teeworlds 2.4.9 → 2.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -6
- package/index.js +16 -1
- package/index.ts +4 -1
- package/lib/client.js +4 -5
- package/lib/client.ts +3 -4
- package/lib/huffman.js +3 -1
- package/lib/huffman.ts +2 -4
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Teeworlds Client
|
|
2
2
|
Library to connect a bot to a Teeworlds server.
|
|
3
3
|
|
|
4
4
|
https://gitlab.com/swarfey/teeworlds-client/-/tree/main/
|
|
5
5
|
https://www.npmjs.com/package/teeworlds
|
|
6
6
|
|
|
7
|
+
# Documentation
|
|
8
|
+
You can find an documentation to what most components do in the [docs/documentation.md](https://gitlab.com/swarfey/teeworlds-client/-/blob/main/docs/documentation.md).
|
|
9
|
+
You can also find a few examples inside of the [docs/examples](https://gitlab.com/swarfey/teeworlds-client/-/tree/main/docs/examples) directory.
|
|
10
|
+
|
|
11
|
+
# Projects using this library
|
|
12
|
+
Note: If you have or know any projects running using this library, please contact me so i can add them, or PR them yourself.
|
|
13
|
+
|
|
14
|
+
A discord which is bridging all discord messages and ingame messages (currently closed source): https://discord.gg/MSYcjYvU6e
|
|
7
15
|
|
|
8
16
|
# Usage
|
|
9
17
|
Example file:
|
|
@@ -87,8 +95,4 @@ process.stdin.on("data", data => {
|
|
|
87
95
|
client.game.Say(data.toString()); // write input in chat
|
|
88
96
|
|
|
89
97
|
})
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
# Documentation
|
|
93
|
-
You can find an documentation to what most components do in the [docs/documentation.md](https://gitlab.com/swarfey/teeworlds-client/-/blob/main/docs/documentation.md).
|
|
94
|
-
You can also find a few examples inside of the [docs/examples](https://gitlab.com/swarfey/teeworlds-client/-/tree/main/docs/examples) directory.
|
|
98
|
+
```
|
package/index.js
CHANGED
|
@@ -10,13 +10,28 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
10
10
|
if (k2 === undefined) k2 = k;
|
|
11
11
|
o[k2] = m[k];
|
|
12
12
|
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
13
18
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
19
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
20
|
};
|
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
+
__setModuleDefault(result, mod);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
16
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.Client = void 0;
|
|
29
|
+
exports.snapshots = exports.Client = void 0;
|
|
18
30
|
var client_1 = require("./lib/client");
|
|
19
31
|
Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return client_1.Client; } });
|
|
20
32
|
__exportStar(require("./lib/MsgPacker"), exports);
|
|
21
33
|
__exportStar(require("./lib/MsgUnpacker"), exports);
|
|
22
34
|
__exportStar(require("./lib/snapshot"), exports);
|
|
35
|
+
__exportStar(require("./lib/huffman"), exports);
|
|
36
|
+
__exportStar(require("./lib/UUIDManager"), exports);
|
|
37
|
+
exports.snapshots = __importStar(require("./lib/snapshots"));
|
package/index.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export { Client } from "./lib/client";
|
|
2
2
|
export * from "./lib/MsgPacker";
|
|
3
3
|
export * from "./lib/MsgUnpacker";
|
|
4
|
-
export * from "./lib/snapshot";
|
|
4
|
+
export * from "./lib/snapshot";
|
|
5
|
+
export * from "./lib/huffman"
|
|
6
|
+
export * from "./lib/UUIDManager"
|
|
7
|
+
export * as snapshots from "./lib/snapshots"
|
package/lib/client.js
CHANGED
|
@@ -27,11 +27,11 @@ var version = require('../package.json').version;
|
|
|
27
27
|
var movement_1 = __importDefault(require("./components/movement"));
|
|
28
28
|
var MsgPacker_1 = require("./MsgPacker");
|
|
29
29
|
var snapshot_1 = require("./snapshot");
|
|
30
|
-
var huffman_1 =
|
|
30
|
+
var huffman_1 = require("./huffman");
|
|
31
31
|
var game_1 = require("./components/game");
|
|
32
32
|
var snapshot_2 = require("./components/snapshot");
|
|
33
33
|
var UUIDManager_1 = require("./UUIDManager");
|
|
34
|
-
var huff = new huffman_1.
|
|
34
|
+
var huff = new huffman_1.Huffman();
|
|
35
35
|
var States;
|
|
36
36
|
(function (States) {
|
|
37
37
|
States[States["STATE_OFFLINE"] = 0] = "STATE_OFFLINE";
|
|
@@ -168,7 +168,6 @@ var Client = /** @class */ (function (_super) {
|
|
|
168
168
|
_this.game = new game_1.Game(_this);
|
|
169
169
|
_this.SnapshotUnpacker = new snapshot_2.SnapshotWrapper(_this);
|
|
170
170
|
_this.UUIDManager = new UUIDManager_1.UUIDManager();
|
|
171
|
-
_this.UUIDManager.RegisterName("i-dont-know@ddnet.tw", NETMSG_Sys.NETMSG_IDONTKNOW);
|
|
172
171
|
_this.UUIDManager.RegisterName("what-is@ddnet.tw", NETMSG_Sys.NETMSG_WHATIS);
|
|
173
172
|
_this.UUIDManager.RegisterName("it-is@ddnet.tw", NETMSG_Sys.NETMSG_ITIS);
|
|
174
173
|
_this.UUIDManager.RegisterName("i-dont-know@ddnet.tw", NETMSG_Sys.NETMSG_IDONTKNOW);
|
|
@@ -443,7 +442,7 @@ var Client = /** @class */ (function (_super) {
|
|
|
443
442
|
var i_am_npm_package = new MsgPacker_1.MsgPacker(0, true, 1);
|
|
444
443
|
i_am_npm_package.AddBuffer(_this.UUIDManager.LookupType(NETMSG_Sys.NETMSG_I_AM_NPM_PACKAGE).hash);
|
|
445
444
|
i_am_npm_package.AddString("https://www.npmjs.com/package/teeworlds/v/".concat(version));
|
|
446
|
-
_this.SendMsgEx([client_version, info
|
|
445
|
+
_this.SendMsgEx([i_am_npm_package, client_version, info]);
|
|
447
446
|
}
|
|
448
447
|
else if (packet[3] == 0x4) {
|
|
449
448
|
// disconnected
|
|
@@ -556,7 +555,7 @@ var Client = /** @class */ (function (_super) {
|
|
|
556
555
|
Crc = unpacker.unpackInt();
|
|
557
556
|
PartSize = unpacker.unpackInt();
|
|
558
557
|
}
|
|
559
|
-
if (
|
|
558
|
+
if (NumParts < 1 || NumParts > 64 || Part < 0 || Part >= NumParts || PartSize < 0 || PartSize > 900)
|
|
560
559
|
return;
|
|
561
560
|
if (GameTick >= _this.currentSnapshotGameTick) {
|
|
562
561
|
if (GameTick != _this.currentSnapshotGameTick) {
|
package/lib/client.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { PlayerInput, PlayerInfo, Projectile, Laser, Pickup, Flag, GameInfo, Gam
|
|
|
11
11
|
|
|
12
12
|
import { MsgPacker } from './MsgPacker';
|
|
13
13
|
import { Item, Snapshot } from './snapshot';
|
|
14
|
-
import Huffman from "./huffman";
|
|
14
|
+
import { Huffman } from "./huffman";
|
|
15
15
|
import { Game } from "./components/game";
|
|
16
16
|
import { SnapshotWrapper } from "./components/snapshot";
|
|
17
17
|
|
|
@@ -295,7 +295,6 @@ export class Client extends EventEmitter {
|
|
|
295
295
|
|
|
296
296
|
this.UUIDManager = new UUIDManager();
|
|
297
297
|
|
|
298
|
-
this.UUIDManager.RegisterName("i-dont-know@ddnet.tw", NETMSG_Sys.NETMSG_IDONTKNOW);
|
|
299
298
|
this.UUIDManager.RegisterName("what-is@ddnet.tw", NETMSG_Sys.NETMSG_WHATIS);
|
|
300
299
|
this.UUIDManager.RegisterName("it-is@ddnet.tw", NETMSG_Sys.NETMSG_ITIS);
|
|
301
300
|
this.UUIDManager.RegisterName("i-dont-know@ddnet.tw", NETMSG_Sys.NETMSG_IDONTKNOW);
|
|
@@ -601,7 +600,7 @@ export class Client extends EventEmitter {
|
|
|
601
600
|
i_am_npm_package.AddString(`https://www.npmjs.com/package/teeworlds/v/${version}`);
|
|
602
601
|
|
|
603
602
|
|
|
604
|
-
this.SendMsgEx([client_version, info
|
|
603
|
+
this.SendMsgEx([i_am_npm_package, client_version, info])
|
|
605
604
|
} else if (packet[3] == 0x4) {
|
|
606
605
|
// disconnected
|
|
607
606
|
this.State = States.STATE_OFFLINE;
|
|
@@ -724,7 +723,7 @@ export class Client extends EventEmitter {
|
|
|
724
723
|
PartSize = unpacker.unpackInt();
|
|
725
724
|
}
|
|
726
725
|
|
|
727
|
-
if (
|
|
726
|
+
if (NumParts < 1 || NumParts > 64 || Part < 0 || Part >= NumParts || PartSize < 0 || PartSize > 900)
|
|
728
727
|
return;
|
|
729
728
|
|
|
730
729
|
if (GameTick >= this.currentSnapshotGameTick) {
|
package/lib/huffman.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Huffman = void 0;
|
|
2
4
|
var FREQ_TABLE = [
|
|
3
5
|
1 << 30, 4545, 2657, 431, 1950, 919, 444, 482, 2244, 617, 838, 542, 715, 1814, 304, 240, 754, 212, 647, 186,
|
|
4
6
|
283, 131, 146, 166, 543, 164, 167, 136, 179, 859, 363, 113, 157, 154, 204, 108, 137, 180, 202, 176,
|
|
@@ -187,4 +189,4 @@ var Huffman = /** @class */ (function () {
|
|
|
187
189
|
};
|
|
188
190
|
return Huffman;
|
|
189
191
|
}());
|
|
190
|
-
|
|
192
|
+
exports.Huffman = Huffman;
|
package/lib/huffman.ts
CHANGED
|
@@ -34,7 +34,7 @@ interface HuffmanConstructNode {
|
|
|
34
34
|
frequency: number;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
class Huffman {
|
|
37
|
+
export class Huffman {
|
|
38
38
|
nodes: HuffmanNode[];
|
|
39
39
|
decode_lut: number[];
|
|
40
40
|
num_nodes: number;
|
|
@@ -223,6 +223,4 @@ class Huffman {
|
|
|
223
223
|
}
|
|
224
224
|
|
|
225
225
|
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
export = Huffman;
|
|
226
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "teeworlds",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.1",
|
|
4
4
|
"description": "Library for (ingame) teeworlds bots.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "index.js",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
},
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|
|
14
|
-
"url": "git+
|
|
14
|
+
"url": "git+gitlab.com/swarfey/teeworlds-client.git"
|
|
15
15
|
},
|
|
16
16
|
"keywords": [
|
|
17
17
|
"teeworlds",
|