Update CS2D (#354)

* Update cs2d.js

* Rename to CS2D

* Update GAMES_LIST.md

* Update cs2d.js
This commit is contained in:
Ernest Paśnik 2023-09-17 23:01:55 +02:00 committed by GitHub
parent d6d09c2886
commit c8e851d6b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 23 deletions

View File

@ -65,7 +65,7 @@
| `corekeeper` | Core Keeper (2022) | [Valve Protocol](#valve) |
| `cs15` | Counter-Strike 1.5 (2002) | |
| `cs16` | Counter-Strike 1.6 (2003) | [Valve Protocol](#valve) |
| `cs2d` | Counter-Strike: 2D (2004) | |
| `cs2d` | CS2D (2004) | |
| `cscz` | Counter-Strike: Condition Zero (2004) | [Valve Protocol](#valve) |
| `csgo` | Counter-Strike: Global Offensive (2012) | [Notes](#csgo), [Valve Protocol](#valve) |
| `css` | Counter-Strike: Source (2004) | [Valve Protocol](#valve) |

View File

@ -73,7 +73,7 @@ corekeeper|Core Keeper (2022)|valve|port=1234,port_query_offset=1
cs15|Counter-Strike 1.5 (2002)|goldsrc|port=27015
cs16|Counter-Strike 1.6 (2003)|valve|port=27015
cs2d|Counter-Strike: 2D (2004)|cs2d|port=36963
cs2d|CS2D (2004)|cs2d|port=36963
cscz|Counter-Strike: Condition Zero (2004)|valve|port=27015
css|Counter-Strike: Source (2004)|valve|port=27015
csgo|Counter-Strike: Global Offensive (2012)|valve|port=27015|doc_notes=csgo

View File

@ -4,8 +4,8 @@ export default class cs2d extends Core {
async run(state) {
{
const reader = await this.sendQuery(
Buffer.from('\x01\x00\x03\x10\x21\xFB\x01\x75\x00', 'binary'),
Buffer.from('\x01\x00\xfb\x01', 'binary')
Buffer.from('\x01\x00\xFB\x01\xF5\x03\xFB\x05', 'binary'),
Buffer.from('\x01\x00\xFB\x01', 'binary')
);
const flags = reader.uint(1);
state.raw.flags = flags;
@ -15,36 +15,32 @@ export default class cs2d extends Core {
state.raw.friendlyFire = this.readFlag(flags, 3);
state.raw.botsEnabled = this.readFlag(flags, 5);
state.raw.luaScripts = this.readFlag(flags, 6);
state.raw.forceLight = this.readFlag(flags, 7);
state.name = this.readString(reader);
state.map = this.readString(reader);
state.raw.numplayers = reader.uint(1);
state.maxplayers = reader.uint(1);
state.raw.gamemode = reader.uint(1);
if (state.raw.botsEnabled) {
state.raw.numbots = reader.uint(1);
if (flags & 32) {
state.raw.gamemode = reader.uint(1);
} else {
state.raw.numbots = 0;
state.raw.gamemode = 0;
}
}
{
const reader = await this.sendQuery(
Buffer.from('\x01\x00\xFB\x05', 'binary'),
Buffer.from('\x01\x00\xFB\x05', 'binary')
);
state.raw.numplayers2 = reader.uint(1);
while(!reader.done()) {
const player = {};
state.raw.numbots = reader.uint(1);
const flags2 = reader.uint(1);
state.raw.flags2 = flags2;
state.raw.recoil = this.readFlag(flags, 0);
state.raw.offScreenDamage = this.readFlag(flags, 1);
state.raw.hasDownloads = this.readFlag(flags, 2);
reader.skip(2);
const players = reader.uint(1);
for (let i = 0; i < players; i++) {
const player = {}
player.id = reader.uint(1);
player.name = this.readString(reader);
player.team = reader.uint(1);
player.score = reader.uint(4);
player.deaths = reader.uint(4);
if (state.bots.length < state.raw.numbots) {
state.bots.push(player);
} else {
state.players.push(player);
}
state.players.push(player);
}
}
}