quake2ts 0.0.254 → 0.0.256
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/package.json +1 -1
- package/packages/client/dist/browser/index.global.js +13 -13
- package/packages/client/dist/browser/index.global.js.map +1 -1
- package/packages/client/dist/cjs/index.cjs +754 -36
- package/packages/client/dist/cjs/index.cjs.map +1 -1
- package/packages/client/dist/esm/index.js +754 -36
- package/packages/client/dist/esm/index.js.map +1 -1
- package/packages/client/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/client/dist/types/index.d.ts +3 -1
- package/packages/client/dist/types/index.d.ts.map +1 -1
- package/packages/client/dist/types/net/connection.d.ts +60 -0
- package/packages/client/dist/types/net/connection.d.ts.map +1 -0
- package/packages/client/dist/types/ui/menu/main.d.ts +2 -0
- package/packages/client/dist/types/ui/menu/main.d.ts.map +1 -1
- package/packages/client/dist/types/ui/menu/multiplayer.d.ts +11 -0
- package/packages/client/dist/types/ui/menu/multiplayer.d.ts.map +1 -0
- package/packages/engine/dist/browser/index.global.js +14 -14
- package/packages/engine/dist/browser/index.global.js.map +1 -1
- package/packages/engine/dist/cjs/index.cjs +2 -0
- package/packages/engine/dist/cjs/index.cjs.map +1 -1
- package/packages/engine/dist/esm/index.js +1 -0
- package/packages/engine/dist/esm/index.js.map +1 -1
- package/packages/engine/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/engine/dist/types/index.d.ts +1 -1
- package/packages/engine/dist/types/index.d.ts.map +1 -1
- package/packages/game/dist/browser/index.global.js +2 -2
- package/packages/game/dist/browser/index.global.js.map +1 -1
- package/packages/game/dist/cjs/index.cjs.map +1 -1
- package/packages/game/dist/esm/index.js.map +1 -1
- package/packages/game/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/shared/dist/browser/index.global.js +1 -1
- package/packages/shared/dist/browser/index.global.js.map +1 -1
- package/packages/shared/dist/cjs/index.cjs +94 -0
- package/packages/shared/dist/cjs/index.cjs.map +1 -1
- package/packages/shared/dist/esm/index.js +93 -0
- package/packages/shared/dist/esm/index.js.map +1 -1
- package/packages/shared/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/shared/dist/types/io/index.d.ts +1 -0
- package/packages/shared/dist/types/io/index.d.ts.map +1 -1
- package/packages/shared/dist/types/io/messageBuilder.d.ts +21 -0
- package/packages/shared/dist/types/io/messageBuilder.d.ts.map +1 -0
- package/packages/tools/dist/tsconfig.tsbuildinfo +1 -1
|
@@ -2060,42 +2060,42 @@ function addReplayFrame(session, cmd, serverFrame, startTime) {
|
|
|
2060
2060
|
});
|
|
2061
2061
|
}
|
|
2062
2062
|
var WATERJUMP_CLEAR = 8 | 16 | 32 | 1024;
|
|
2063
|
-
var ServerCommand = /* @__PURE__ */ ((
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
return
|
|
2063
|
+
var ServerCommand = /* @__PURE__ */ ((ServerCommand22) => {
|
|
2064
|
+
ServerCommand22[ServerCommand22["bad"] = 0] = "bad";
|
|
2065
|
+
ServerCommand22[ServerCommand22["muzzleflash"] = 1] = "muzzleflash";
|
|
2066
|
+
ServerCommand22[ServerCommand22["muzzleflash2"] = 2] = "muzzleflash2";
|
|
2067
|
+
ServerCommand22[ServerCommand22["temp_entity"] = 3] = "temp_entity";
|
|
2068
|
+
ServerCommand22[ServerCommand22["layout"] = 4] = "layout";
|
|
2069
|
+
ServerCommand22[ServerCommand22["inventory"] = 5] = "inventory";
|
|
2070
|
+
ServerCommand22[ServerCommand22["nop"] = 6] = "nop";
|
|
2071
|
+
ServerCommand22[ServerCommand22["disconnect"] = 7] = "disconnect";
|
|
2072
|
+
ServerCommand22[ServerCommand22["reconnect"] = 8] = "reconnect";
|
|
2073
|
+
ServerCommand22[ServerCommand22["sound"] = 9] = "sound";
|
|
2074
|
+
ServerCommand22[ServerCommand22["print"] = 10] = "print";
|
|
2075
|
+
ServerCommand22[ServerCommand22["stufftext"] = 11] = "stufftext";
|
|
2076
|
+
ServerCommand22[ServerCommand22["serverdata"] = 12] = "serverdata";
|
|
2077
|
+
ServerCommand22[ServerCommand22["configstring"] = 13] = "configstring";
|
|
2078
|
+
ServerCommand22[ServerCommand22["spawnbaseline"] = 14] = "spawnbaseline";
|
|
2079
|
+
ServerCommand22[ServerCommand22["centerprint"] = 15] = "centerprint";
|
|
2080
|
+
ServerCommand22[ServerCommand22["download"] = 16] = "download";
|
|
2081
|
+
ServerCommand22[ServerCommand22["playerinfo"] = 17] = "playerinfo";
|
|
2082
|
+
ServerCommand22[ServerCommand22["packetentities"] = 18] = "packetentities";
|
|
2083
|
+
ServerCommand22[ServerCommand22["deltapacketentities"] = 19] = "deltapacketentities";
|
|
2084
|
+
ServerCommand22[ServerCommand22["frame"] = 20] = "frame";
|
|
2085
|
+
ServerCommand22[ServerCommand22["splitclient"] = 21] = "splitclient";
|
|
2086
|
+
ServerCommand22[ServerCommand22["configblast"] = 22] = "configblast";
|
|
2087
|
+
ServerCommand22[ServerCommand22["spawnbaselineblast"] = 23] = "spawnbaselineblast";
|
|
2088
|
+
ServerCommand22[ServerCommand22["level_restart"] = 24] = "level_restart";
|
|
2089
|
+
ServerCommand22[ServerCommand22["damage"] = 25] = "damage";
|
|
2090
|
+
ServerCommand22[ServerCommand22["locprint"] = 26] = "locprint";
|
|
2091
|
+
ServerCommand22[ServerCommand22["fog"] = 27] = "fog";
|
|
2092
|
+
ServerCommand22[ServerCommand22["waitingforplayers"] = 28] = "waitingforplayers";
|
|
2093
|
+
ServerCommand22[ServerCommand22["bot_chat"] = 29] = "bot_chat";
|
|
2094
|
+
ServerCommand22[ServerCommand22["poi"] = 30] = "poi";
|
|
2095
|
+
ServerCommand22[ServerCommand22["help_path"] = 31] = "help_path";
|
|
2096
|
+
ServerCommand22[ServerCommand22["muzzleflash3"] = 32] = "muzzleflash3";
|
|
2097
|
+
ServerCommand22[ServerCommand22["achievement"] = 33] = "achievement";
|
|
2098
|
+
return ServerCommand22;
|
|
2099
2099
|
})(ServerCommand || {});
|
|
2100
2100
|
var TempEntity = /* @__PURE__ */ ((TempEntity2) => {
|
|
2101
2101
|
TempEntity2[TempEntity2["GUNSHOT"] = 0] = "GUNSHOT";
|
|
@@ -8078,6 +8078,170 @@ function angleMod(angle2) {
|
|
|
8078
8078
|
const value = angle2 % 360;
|
|
8079
8079
|
return value < 0 ? 360 + value : value;
|
|
8080
8080
|
}
|
|
8081
|
+
var ANORMS2 = [
|
|
8082
|
+
[-0.525731, 0, 0.850651],
|
|
8083
|
+
[-0.442863, 0.238856, 0.864188],
|
|
8084
|
+
[-0.295242, 0, 0.955423],
|
|
8085
|
+
[-0.309017, 0.5, 0.809017],
|
|
8086
|
+
[-0.16246, 0.262866, 0.951056],
|
|
8087
|
+
[0, 0, 1],
|
|
8088
|
+
[0, 0.850651, 0.525731],
|
|
8089
|
+
[-0.147621, 0.716567, 0.681718],
|
|
8090
|
+
[0.147621, 0.716567, 0.681718],
|
|
8091
|
+
[0, 0.525731, 0.850651],
|
|
8092
|
+
[0.309017, 0.5, 0.809017],
|
|
8093
|
+
[0.525731, 0, 0.850651],
|
|
8094
|
+
[0.295242, 0, 0.955423],
|
|
8095
|
+
[0.442863, 0.238856, 0.864188],
|
|
8096
|
+
[0.16246, 0.262866, 0.951056],
|
|
8097
|
+
[-0.681718, 0.147621, 0.716567],
|
|
8098
|
+
[-0.809017, 0.309017, 0.5],
|
|
8099
|
+
[-0.587785, 0.425325, 0.688191],
|
|
8100
|
+
[-0.850651, 0.525731, 0],
|
|
8101
|
+
[-0.864188, 0.442863, 0.238856],
|
|
8102
|
+
[-0.716567, 0.681718, 0.147621],
|
|
8103
|
+
[-0.688191, 0.587785, 0.425325],
|
|
8104
|
+
[-0.5, 0.809017, 0.309017],
|
|
8105
|
+
[-0.238856, 0.864188, 0.442863],
|
|
8106
|
+
[-0.425325, 0.688191, 0.587785],
|
|
8107
|
+
[-0.716567, 0.681718, -0.147621],
|
|
8108
|
+
[-0.5, 0.809017, -0.309017],
|
|
8109
|
+
[-0.525731, 0.850651, 0],
|
|
8110
|
+
[0, 0.850651, -0.525731],
|
|
8111
|
+
[-0.238856, 0.864188, -0.442863],
|
|
8112
|
+
[0, 0.955423, -0.295242],
|
|
8113
|
+
[-0.262866, 0.951056, -0.16246],
|
|
8114
|
+
[0, 1, 0],
|
|
8115
|
+
[0, 0.955423, 0.295242],
|
|
8116
|
+
[-0.262866, 0.951056, 0.16246],
|
|
8117
|
+
[0.238856, 0.864188, 0.442863],
|
|
8118
|
+
[0.262866, 0.951056, 0.16246],
|
|
8119
|
+
[0.5, 0.809017, 0.309017],
|
|
8120
|
+
[0.238856, 0.864188, -0.442863],
|
|
8121
|
+
[0.262866, 0.951056, -0.16246],
|
|
8122
|
+
[0.5, 0.809017, -0.309017],
|
|
8123
|
+
[0.850651, 0.525731, 0],
|
|
8124
|
+
[0.716567, 0.681718, 0.147621],
|
|
8125
|
+
[0.716567, 0.681718, -0.147621],
|
|
8126
|
+
[0.525731, 0.850651, 0],
|
|
8127
|
+
[0.425325, 0.688191, 0.587785],
|
|
8128
|
+
[0.864188, 0.442863, 0.238856],
|
|
8129
|
+
[0.688191, 0.587785, 0.425325],
|
|
8130
|
+
[0.809017, 0.309017, 0.5],
|
|
8131
|
+
[0.681718, 0.147621, 0.716567],
|
|
8132
|
+
[0.587785, 0.425325, 0.688191],
|
|
8133
|
+
[0.955423, 0.295242, 0],
|
|
8134
|
+
[1, 0, 0],
|
|
8135
|
+
[0.951056, 0.16246, 0.262866],
|
|
8136
|
+
[0.850651, -0.525731, 0],
|
|
8137
|
+
[0.955423, -0.295242, 0],
|
|
8138
|
+
[0.864188, -0.442863, 0.238856],
|
|
8139
|
+
[0.951056, -0.16246, 0.262866],
|
|
8140
|
+
[0.809017, -0.309017, 0.5],
|
|
8141
|
+
[0.681718, -0.147621, 0.716567],
|
|
8142
|
+
[0.850651, 0, 0.525731],
|
|
8143
|
+
[0.864188, 0.442863, -0.238856],
|
|
8144
|
+
[0.809017, 0.309017, -0.5],
|
|
8145
|
+
[0.951056, 0.16246, -0.262866],
|
|
8146
|
+
[0.525731, 0, -0.850651],
|
|
8147
|
+
[0.681718, 0.147621, -0.716567],
|
|
8148
|
+
[0.681718, -0.147621, -0.716567],
|
|
8149
|
+
[0.850651, 0, -0.525731],
|
|
8150
|
+
[0.809017, -0.309017, -0.5],
|
|
8151
|
+
[0.864188, -0.442863, -0.238856],
|
|
8152
|
+
[0.951056, -0.16246, -0.262866],
|
|
8153
|
+
[0.147621, 0.716567, -0.681718],
|
|
8154
|
+
[0.309017, 0.5, -0.809017],
|
|
8155
|
+
[0.425325, 0.688191, -0.587785],
|
|
8156
|
+
[0.442863, 0.238856, -0.864188],
|
|
8157
|
+
[0.587785, 0.425325, -0.688191],
|
|
8158
|
+
[0.688191, 0.587785, -0.425325],
|
|
8159
|
+
[-0.147621, 0.716567, -0.681718],
|
|
8160
|
+
[-0.309017, 0.5, -0.809017],
|
|
8161
|
+
[0, 0.525731, -0.850651],
|
|
8162
|
+
[-0.525731, 0, -0.850651],
|
|
8163
|
+
[-0.442863, 0.238856, -0.864188],
|
|
8164
|
+
[-0.295242, 0, -0.955423],
|
|
8165
|
+
[-0.16246, 0.262866, -0.951056],
|
|
8166
|
+
[0, 0, -1],
|
|
8167
|
+
[0.295242, 0, -0.955423],
|
|
8168
|
+
[0.16246, 0.262866, -0.951056],
|
|
8169
|
+
[-0.442863, -0.238856, -0.864188],
|
|
8170
|
+
[-0.309017, -0.5, -0.809017],
|
|
8171
|
+
[-0.16246, -0.262866, -0.951056],
|
|
8172
|
+
[0, -0.850651, -0.525731],
|
|
8173
|
+
[-0.147621, -0.716567, -0.681718],
|
|
8174
|
+
[0.147621, -0.716567, -0.681718],
|
|
8175
|
+
[0, -0.525731, -0.850651],
|
|
8176
|
+
[0.309017, -0.5, -0.809017],
|
|
8177
|
+
[0.442863, -0.238856, -0.864188],
|
|
8178
|
+
[0.16246, -0.262866, -0.951056],
|
|
8179
|
+
[0.238856, -0.864188, -0.442863],
|
|
8180
|
+
[0.5, -0.809017, -0.309017],
|
|
8181
|
+
[0.425325, -0.688191, -0.587785],
|
|
8182
|
+
[0.716567, -0.681718, -0.147621],
|
|
8183
|
+
[0.688191, -0.587785, -0.425325],
|
|
8184
|
+
[0.587785, -0.425325, -0.688191],
|
|
8185
|
+
[0, -0.955423, -0.295242],
|
|
8186
|
+
[0, -1, 0],
|
|
8187
|
+
[0.262866, -0.951056, -0.16246],
|
|
8188
|
+
[0, -0.850651, 0.525731],
|
|
8189
|
+
[0, -0.955423, 0.295242],
|
|
8190
|
+
[0.238856, -0.864188, 0.442863],
|
|
8191
|
+
[0.262866, -0.951056, 0.16246],
|
|
8192
|
+
[0.5, -0.809017, 0.309017],
|
|
8193
|
+
[0.716567, -0.681718, 0.147621],
|
|
8194
|
+
[0.525731, -0.850651, 0],
|
|
8195
|
+
[-0.238856, -0.864188, -0.442863],
|
|
8196
|
+
[-0.5, -0.809017, -0.309017],
|
|
8197
|
+
[-0.262866, -0.951056, -0.16246],
|
|
8198
|
+
[-0.850651, -0.525731, 0],
|
|
8199
|
+
[-0.716567, -0.681718, -0.147621],
|
|
8200
|
+
[-0.716567, -0.681718, 0.147621],
|
|
8201
|
+
[-0.525731, -0.850651, 0],
|
|
8202
|
+
[-0.5, -0.809017, 0.309017],
|
|
8203
|
+
[-0.238856, -0.864188, 0.442863],
|
|
8204
|
+
[-0.262866, -0.951056, 0.16246],
|
|
8205
|
+
[-0.864188, -0.442863, 0.238856],
|
|
8206
|
+
[-0.809017, -0.309017, 0.5],
|
|
8207
|
+
[-0.688191, -0.587785, 0.425325],
|
|
8208
|
+
[-0.681718, -0.147621, 0.716567],
|
|
8209
|
+
[-0.442863, -0.238856, 0.864188],
|
|
8210
|
+
[-0.587785, -0.425325, 0.688191],
|
|
8211
|
+
[-0.309017, -0.5, 0.809017],
|
|
8212
|
+
[-0.147621, -0.716567, 0.681718],
|
|
8213
|
+
[-0.425325, -0.688191, 0.587785],
|
|
8214
|
+
[-0.16246, -0.262866, 0.951056],
|
|
8215
|
+
[0.442863, -0.238856, 0.864188],
|
|
8216
|
+
[0.16246, -0.262866, 0.951056],
|
|
8217
|
+
[0.309017, -0.5, 0.809017],
|
|
8218
|
+
[0.147621, -0.716567, 0.681718],
|
|
8219
|
+
[0, -0.525731, 0.850651],
|
|
8220
|
+
[0.425325, -0.688191, 0.587785],
|
|
8221
|
+
[0.587785, -0.425325, 0.688191],
|
|
8222
|
+
[0.688191, -0.587785, 0.425325],
|
|
8223
|
+
[-0.955423, 0.295242, 0],
|
|
8224
|
+
[-0.951056, 0.16246, 0.262866],
|
|
8225
|
+
[-1, 0, 0],
|
|
8226
|
+
[-0.850651, 0, 0.525731],
|
|
8227
|
+
[-0.955423, -0.295242, 0],
|
|
8228
|
+
[-0.951056, -0.16246, 0.262866],
|
|
8229
|
+
[-0.864188, 0.442863, -0.238856],
|
|
8230
|
+
[-0.951056, 0.16246, -0.262866],
|
|
8231
|
+
[-0.809017, 0.309017, -0.5],
|
|
8232
|
+
[-0.864188, -0.442863, -0.238856],
|
|
8233
|
+
[-0.951056, -0.16246, -0.262866],
|
|
8234
|
+
[-0.809017, -0.309017, -0.5],
|
|
8235
|
+
[-0.681718, 0.147621, -0.716567],
|
|
8236
|
+
[-0.681718, -0.147621, -0.716567],
|
|
8237
|
+
[-0.850651, 0, -0.525731],
|
|
8238
|
+
[-0.688191, 0.587785, -0.425325],
|
|
8239
|
+
[-0.587785, 0.425325, -0.688191],
|
|
8240
|
+
[-0.425325, 0.688191, -0.587785],
|
|
8241
|
+
[-0.425325, -0.688191, -0.587785],
|
|
8242
|
+
[-0.587785, -0.425325, -0.688191],
|
|
8243
|
+
[-0.688191, -0.587785, -0.425325]
|
|
8244
|
+
];
|
|
8081
8245
|
var CONTENTS_SOLID2 = 1 << 0;
|
|
8082
8246
|
var CONTENTS_WINDOW2 = 1 << 1;
|
|
8083
8247
|
var CONTENTS_AUX2 = 1 << 2;
|
|
@@ -8277,6 +8441,14 @@ function mouseDeltaToViewDelta(delta, options) {
|
|
|
8277
8441
|
z: 0
|
|
8278
8442
|
};
|
|
8279
8443
|
}
|
|
8444
|
+
var ClientCommand = /* @__PURE__ */ ((ClientCommand2) => {
|
|
8445
|
+
ClientCommand2[ClientCommand2["bad"] = 0] = "bad";
|
|
8446
|
+
ClientCommand2[ClientCommand2["nop"] = 1] = "nop";
|
|
8447
|
+
ClientCommand2[ClientCommand2["move"] = 2] = "move";
|
|
8448
|
+
ClientCommand2[ClientCommand2["userinfo"] = 3] = "userinfo";
|
|
8449
|
+
ClientCommand2[ClientCommand2["stringcmd"] = 4] = "stringcmd";
|
|
8450
|
+
return ClientCommand2;
|
|
8451
|
+
})(ClientCommand || {});
|
|
8280
8452
|
var MZ_BLASTER = 0;
|
|
8281
8453
|
var MZ_MACHINEGUN = 1;
|
|
8282
8454
|
var MZ_SHOTGUN = 2;
|
|
@@ -8535,6 +8707,211 @@ var U_MODEL23 = 1 << 0;
|
|
|
8535
8707
|
var U_MODEL33 = 1 << 1;
|
|
8536
8708
|
var U_MODEL43 = 1 << 2;
|
|
8537
8709
|
var U_REMOVE3 = 32768;
|
|
8710
|
+
var BinaryStream2 = class {
|
|
8711
|
+
constructor(buffer) {
|
|
8712
|
+
if (buffer instanceof Uint8Array) {
|
|
8713
|
+
this.view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
8714
|
+
} else {
|
|
8715
|
+
this.view = new DataView(buffer);
|
|
8716
|
+
}
|
|
8717
|
+
this.offset = 0;
|
|
8718
|
+
this.length = this.view.byteLength;
|
|
8719
|
+
}
|
|
8720
|
+
getPosition() {
|
|
8721
|
+
return this.offset;
|
|
8722
|
+
}
|
|
8723
|
+
seek(position) {
|
|
8724
|
+
if (position < 0 || position > this.length) {
|
|
8725
|
+
throw new Error(`Seek out of bounds: ${position} (length: ${this.length})`);
|
|
8726
|
+
}
|
|
8727
|
+
this.offset = position;
|
|
8728
|
+
}
|
|
8729
|
+
hasMore() {
|
|
8730
|
+
return this.offset < this.length;
|
|
8731
|
+
}
|
|
8732
|
+
readChar() {
|
|
8733
|
+
const value = this.view.getInt8(this.offset);
|
|
8734
|
+
this.offset += 1;
|
|
8735
|
+
return value;
|
|
8736
|
+
}
|
|
8737
|
+
readByte() {
|
|
8738
|
+
const value = this.view.getUint8(this.offset);
|
|
8739
|
+
this.offset += 1;
|
|
8740
|
+
return value;
|
|
8741
|
+
}
|
|
8742
|
+
readShort() {
|
|
8743
|
+
const value = this.view.getInt16(this.offset, true);
|
|
8744
|
+
this.offset += 2;
|
|
8745
|
+
return value;
|
|
8746
|
+
}
|
|
8747
|
+
readUShort() {
|
|
8748
|
+
const value = this.view.getUint16(this.offset, true);
|
|
8749
|
+
this.offset += 2;
|
|
8750
|
+
return value;
|
|
8751
|
+
}
|
|
8752
|
+
readLong() {
|
|
8753
|
+
const value = this.view.getInt32(this.offset, true);
|
|
8754
|
+
this.offset += 4;
|
|
8755
|
+
return value;
|
|
8756
|
+
}
|
|
8757
|
+
readULong() {
|
|
8758
|
+
const value = this.view.getUint32(this.offset, true);
|
|
8759
|
+
this.offset += 4;
|
|
8760
|
+
return value;
|
|
8761
|
+
}
|
|
8762
|
+
readFloat() {
|
|
8763
|
+
const value = this.view.getFloat32(this.offset, true);
|
|
8764
|
+
this.offset += 4;
|
|
8765
|
+
return value;
|
|
8766
|
+
}
|
|
8767
|
+
readString() {
|
|
8768
|
+
let str3 = "";
|
|
8769
|
+
while (this.offset < this.length) {
|
|
8770
|
+
const charCode = this.readChar();
|
|
8771
|
+
if (charCode === -1 || charCode === 0) {
|
|
8772
|
+
break;
|
|
8773
|
+
}
|
|
8774
|
+
str3 += String.fromCharCode(charCode);
|
|
8775
|
+
}
|
|
8776
|
+
return str3;
|
|
8777
|
+
}
|
|
8778
|
+
readStringLine() {
|
|
8779
|
+
let str3 = "";
|
|
8780
|
+
while (this.offset < this.length) {
|
|
8781
|
+
const charCode = this.readChar();
|
|
8782
|
+
if (charCode === -1 || charCode === 0 || charCode === 10) {
|
|
8783
|
+
break;
|
|
8784
|
+
}
|
|
8785
|
+
str3 += String.fromCharCode(charCode);
|
|
8786
|
+
}
|
|
8787
|
+
return str3;
|
|
8788
|
+
}
|
|
8789
|
+
readCoord() {
|
|
8790
|
+
return this.readShort() * (1 / 8);
|
|
8791
|
+
}
|
|
8792
|
+
readAngle() {
|
|
8793
|
+
return this.readChar() * (360 / 256);
|
|
8794
|
+
}
|
|
8795
|
+
readAngle16() {
|
|
8796
|
+
return this.readShort() * 360 / 65536;
|
|
8797
|
+
}
|
|
8798
|
+
readData(length2) {
|
|
8799
|
+
if (this.offset + length2 > this.length) {
|
|
8800
|
+
throw new Error(`Read out of bounds: ${this.offset + length2} (length: ${this.length})`);
|
|
8801
|
+
}
|
|
8802
|
+
const data = new Uint8Array(this.view.buffer, this.view.byteOffset + this.offset, length2);
|
|
8803
|
+
this.offset += length2;
|
|
8804
|
+
return new Uint8Array(data);
|
|
8805
|
+
}
|
|
8806
|
+
readPos(out) {
|
|
8807
|
+
out.x = this.readCoord();
|
|
8808
|
+
out.y = this.readCoord();
|
|
8809
|
+
out.z = this.readCoord();
|
|
8810
|
+
}
|
|
8811
|
+
readDir(out) {
|
|
8812
|
+
const b = this.readByte();
|
|
8813
|
+
if (b >= 162) {
|
|
8814
|
+
out.x = 0;
|
|
8815
|
+
out.y = 0;
|
|
8816
|
+
out.z = 0;
|
|
8817
|
+
return;
|
|
8818
|
+
}
|
|
8819
|
+
const norm = ANORMS2[b];
|
|
8820
|
+
out.x = norm[0];
|
|
8821
|
+
out.y = norm[1];
|
|
8822
|
+
out.z = norm[2];
|
|
8823
|
+
}
|
|
8824
|
+
};
|
|
8825
|
+
var NetworkMessageBuilder = class {
|
|
8826
|
+
constructor(initialSize = 1024) {
|
|
8827
|
+
this.buffer = new Uint8Array(initialSize);
|
|
8828
|
+
this.view = new DataView(this.buffer.buffer);
|
|
8829
|
+
this.offset = 0;
|
|
8830
|
+
}
|
|
8831
|
+
ensureCapacity(needed) {
|
|
8832
|
+
if (this.offset + needed > this.buffer.length) {
|
|
8833
|
+
const newSize = Math.max(this.buffer.length * 2, this.offset + needed);
|
|
8834
|
+
const newBuffer = new Uint8Array(newSize);
|
|
8835
|
+
newBuffer.set(this.buffer);
|
|
8836
|
+
this.buffer = newBuffer;
|
|
8837
|
+
this.view = new DataView(this.buffer.buffer);
|
|
8838
|
+
}
|
|
8839
|
+
}
|
|
8840
|
+
getData() {
|
|
8841
|
+
return this.buffer.slice(0, this.offset);
|
|
8842
|
+
}
|
|
8843
|
+
writeByte(value) {
|
|
8844
|
+
this.ensureCapacity(1);
|
|
8845
|
+
this.view.setUint8(this.offset, value);
|
|
8846
|
+
this.offset += 1;
|
|
8847
|
+
}
|
|
8848
|
+
writeChar(value) {
|
|
8849
|
+
this.ensureCapacity(1);
|
|
8850
|
+
this.view.setInt8(this.offset, value);
|
|
8851
|
+
this.offset += 1;
|
|
8852
|
+
}
|
|
8853
|
+
writeShort(value) {
|
|
8854
|
+
this.ensureCapacity(2);
|
|
8855
|
+
this.view.setInt16(this.offset, value, true);
|
|
8856
|
+
this.offset += 2;
|
|
8857
|
+
}
|
|
8858
|
+
writeUShort(value) {
|
|
8859
|
+
this.ensureCapacity(2);
|
|
8860
|
+
this.view.setUint16(this.offset, value, true);
|
|
8861
|
+
this.offset += 2;
|
|
8862
|
+
}
|
|
8863
|
+
writeLong(value) {
|
|
8864
|
+
this.ensureCapacity(4);
|
|
8865
|
+
this.view.setInt32(this.offset, value, true);
|
|
8866
|
+
this.offset += 4;
|
|
8867
|
+
}
|
|
8868
|
+
writeFloat(value) {
|
|
8869
|
+
this.ensureCapacity(4);
|
|
8870
|
+
this.view.setFloat32(this.offset, value, true);
|
|
8871
|
+
this.offset += 4;
|
|
8872
|
+
}
|
|
8873
|
+
writeString(value) {
|
|
8874
|
+
const len2 = value.length + 1;
|
|
8875
|
+
this.ensureCapacity(len2);
|
|
8876
|
+
for (let i = 0; i < value.length; i++) {
|
|
8877
|
+
this.view.setUint8(this.offset + i, value.charCodeAt(i));
|
|
8878
|
+
}
|
|
8879
|
+
this.view.setUint8(this.offset + value.length, 0);
|
|
8880
|
+
this.offset += len2;
|
|
8881
|
+
}
|
|
8882
|
+
writeData(data) {
|
|
8883
|
+
this.ensureCapacity(data.length);
|
|
8884
|
+
this.buffer.set(data, this.offset);
|
|
8885
|
+
this.offset += data.length;
|
|
8886
|
+
}
|
|
8887
|
+
writeCoord(value) {
|
|
8888
|
+
this.writeShort(Math.round(value * 8));
|
|
8889
|
+
}
|
|
8890
|
+
writeAngle(value) {
|
|
8891
|
+
this.writeByte(Math.round(value * 256 / 360) & 255);
|
|
8892
|
+
}
|
|
8893
|
+
writeAngle16(value) {
|
|
8894
|
+
this.writeShort(Math.round(value * 65536 / 360));
|
|
8895
|
+
}
|
|
8896
|
+
writeDir(x, y, z) {
|
|
8897
|
+
let best = 0;
|
|
8898
|
+
let bestDot = -999999;
|
|
8899
|
+
const len2 = Math.sqrt(x * x + y * y + z * z);
|
|
8900
|
+
if (len2 > 0) {
|
|
8901
|
+
x /= len2;
|
|
8902
|
+
y /= len2;
|
|
8903
|
+
z /= len2;
|
|
8904
|
+
for (let i = 0; i < 162; i++) {
|
|
8905
|
+
const dot2 = x * ANORMS2[i][0] + y * ANORMS2[i][1] + z * ANORMS2[i][2];
|
|
8906
|
+
if (dot2 > bestDot) {
|
|
8907
|
+
bestDot = dot2;
|
|
8908
|
+
best = i;
|
|
8909
|
+
}
|
|
8910
|
+
}
|
|
8911
|
+
}
|
|
8912
|
+
this.writeByte(best);
|
|
8913
|
+
}
|
|
8914
|
+
};
|
|
8538
8915
|
var AmmoType2 = /* @__PURE__ */ ((AmmoType22) => {
|
|
8539
8916
|
AmmoType22[AmmoType22["Bullets"] = 0] = "Bullets";
|
|
8540
8917
|
AmmoType22[AmmoType22["Shells"] = 1] = "Shells";
|
|
@@ -9504,6 +9881,16 @@ var MainMenuFactory = class {
|
|
|
9504
9881
|
this.menuSystem.pushMenu(this.createDifficultyMenu());
|
|
9505
9882
|
}
|
|
9506
9883
|
},
|
|
9884
|
+
{
|
|
9885
|
+
label: "Multiplayer",
|
|
9886
|
+
action: () => {
|
|
9887
|
+
if (this.options.multiplayerFactory) {
|
|
9888
|
+
this.menuSystem.pushMenu(this.options.multiplayerFactory.createMultiplayerMenu());
|
|
9889
|
+
} else {
|
|
9890
|
+
console.warn("Multiplayer factory not configured");
|
|
9891
|
+
}
|
|
9892
|
+
}
|
|
9893
|
+
},
|
|
9507
9894
|
{
|
|
9508
9895
|
label: "Load Game",
|
|
9509
9896
|
action: () => {
|
|
@@ -10078,6 +10465,74 @@ var PauseMenuFactory = class {
|
|
|
10078
10465
|
}
|
|
10079
10466
|
};
|
|
10080
10467
|
|
|
10468
|
+
// src/ui/menu/multiplayer.ts
|
|
10469
|
+
var MultiplayerMenuFactory = class {
|
|
10470
|
+
constructor(menuSystem, connection) {
|
|
10471
|
+
this.menuSystem = menuSystem;
|
|
10472
|
+
this.connection = connection;
|
|
10473
|
+
}
|
|
10474
|
+
createMultiplayerMenu(initialAddress = "localhost:27910", status = "") {
|
|
10475
|
+
let address = initialAddress;
|
|
10476
|
+
const items = [];
|
|
10477
|
+
if (status) {
|
|
10478
|
+
items.push({
|
|
10479
|
+
label: status,
|
|
10480
|
+
action: () => {
|
|
10481
|
+
}
|
|
10482
|
+
// No-op
|
|
10483
|
+
});
|
|
10484
|
+
}
|
|
10485
|
+
items.push(
|
|
10486
|
+
{
|
|
10487
|
+
label: "Address: " + address,
|
|
10488
|
+
action: () => {
|
|
10489
|
+
if (typeof window !== "undefined") {
|
|
10490
|
+
const newAddr = window.prompt("Enter Server Address", address);
|
|
10491
|
+
if (newAddr) {
|
|
10492
|
+
address = newAddr;
|
|
10493
|
+
this.refreshMenu(address);
|
|
10494
|
+
}
|
|
10495
|
+
}
|
|
10496
|
+
}
|
|
10497
|
+
},
|
|
10498
|
+
{
|
|
10499
|
+
label: "Connect",
|
|
10500
|
+
action: () => {
|
|
10501
|
+
this.refreshMenu(address, "Connecting...");
|
|
10502
|
+
this.connection.connect("ws://" + address).then(() => {
|
|
10503
|
+
this.menuSystem.closeAll();
|
|
10504
|
+
}).catch((err2) => {
|
|
10505
|
+
console.error(err2);
|
|
10506
|
+
const failStatus = "Failed: " + (err2.message || "Unknown error");
|
|
10507
|
+
this.refreshMenu(address, failStatus);
|
|
10508
|
+
});
|
|
10509
|
+
}
|
|
10510
|
+
},
|
|
10511
|
+
{
|
|
10512
|
+
label: "Disconnect",
|
|
10513
|
+
action: () => {
|
|
10514
|
+
this.connection.disconnect();
|
|
10515
|
+
this.refreshMenu(address, "Disconnected");
|
|
10516
|
+
}
|
|
10517
|
+
},
|
|
10518
|
+
{
|
|
10519
|
+
label: "Back",
|
|
10520
|
+
action: () => {
|
|
10521
|
+
this.menuSystem.popMenu();
|
|
10522
|
+
}
|
|
10523
|
+
}
|
|
10524
|
+
);
|
|
10525
|
+
return {
|
|
10526
|
+
title: "Multiplayer",
|
|
10527
|
+
items
|
|
10528
|
+
};
|
|
10529
|
+
}
|
|
10530
|
+
refreshMenu(address, status = "") {
|
|
10531
|
+
this.menuSystem.popMenu();
|
|
10532
|
+
this.menuSystem.pushMenu(this.createMultiplayerMenu(address, status));
|
|
10533
|
+
}
|
|
10534
|
+
};
|
|
10535
|
+
|
|
10081
10536
|
// src/ui/menu/render.ts
|
|
10082
10537
|
function Draw_Menu(renderer, state, width, height) {
|
|
10083
10538
|
if (!state.activeMenu) {
|
|
@@ -10356,6 +10811,233 @@ function buildRenderableEntities(latestEntities, previousEntities, alpha, config
|
|
|
10356
10811
|
return renderables;
|
|
10357
10812
|
}
|
|
10358
10813
|
|
|
10814
|
+
// src/net/browserWsDriver.ts
|
|
10815
|
+
var BrowserWebSocketNetDriver = class {
|
|
10816
|
+
constructor() {
|
|
10817
|
+
this.socket = null;
|
|
10818
|
+
this.messageCallback = null;
|
|
10819
|
+
this.closeCallback = null;
|
|
10820
|
+
this.errorCallback = null;
|
|
10821
|
+
}
|
|
10822
|
+
async connect(url) {
|
|
10823
|
+
return new Promise((resolve, reject) => {
|
|
10824
|
+
try {
|
|
10825
|
+
this.socket = new WebSocket(url);
|
|
10826
|
+
this.socket.binaryType = "arraybuffer";
|
|
10827
|
+
this.socket.onopen = () => {
|
|
10828
|
+
resolve();
|
|
10829
|
+
};
|
|
10830
|
+
this.socket.onerror = (event) => {
|
|
10831
|
+
const error = new Error("WebSocket connection error");
|
|
10832
|
+
if (this.errorCallback) {
|
|
10833
|
+
this.errorCallback(error);
|
|
10834
|
+
}
|
|
10835
|
+
reject(error);
|
|
10836
|
+
};
|
|
10837
|
+
this.socket.onclose = () => {
|
|
10838
|
+
if (this.closeCallback) {
|
|
10839
|
+
this.closeCallback();
|
|
10840
|
+
}
|
|
10841
|
+
this.socket = null;
|
|
10842
|
+
};
|
|
10843
|
+
this.socket.onmessage = (event) => {
|
|
10844
|
+
if (this.messageCallback) {
|
|
10845
|
+
if (event.data instanceof ArrayBuffer) {
|
|
10846
|
+
this.messageCallback(new Uint8Array(event.data));
|
|
10847
|
+
} else {
|
|
10848
|
+
console.warn("Received non-binary message from server");
|
|
10849
|
+
}
|
|
10850
|
+
}
|
|
10851
|
+
};
|
|
10852
|
+
} catch (e) {
|
|
10853
|
+
reject(e);
|
|
10854
|
+
}
|
|
10855
|
+
});
|
|
10856
|
+
}
|
|
10857
|
+
disconnect() {
|
|
10858
|
+
if (this.socket) {
|
|
10859
|
+
this.socket.close();
|
|
10860
|
+
this.socket = null;
|
|
10861
|
+
}
|
|
10862
|
+
}
|
|
10863
|
+
send(data) {
|
|
10864
|
+
if (this.socket && this.socket.readyState === WebSocket.OPEN) {
|
|
10865
|
+
this.socket.send(data);
|
|
10866
|
+
} else {
|
|
10867
|
+
console.warn("Attempted to send data on closed or connecting socket");
|
|
10868
|
+
}
|
|
10869
|
+
}
|
|
10870
|
+
onMessage(callback) {
|
|
10871
|
+
this.messageCallback = callback;
|
|
10872
|
+
}
|
|
10873
|
+
onClose(callback) {
|
|
10874
|
+
this.closeCallback = callback;
|
|
10875
|
+
}
|
|
10876
|
+
onError(callback) {
|
|
10877
|
+
this.errorCallback = callback;
|
|
10878
|
+
}
|
|
10879
|
+
isConnected() {
|
|
10880
|
+
return this.socket !== null && this.socket.readyState === WebSocket.OPEN;
|
|
10881
|
+
}
|
|
10882
|
+
};
|
|
10883
|
+
|
|
10884
|
+
// src/net/connection.ts
|
|
10885
|
+
var MultiplayerConnection = class {
|
|
10886
|
+
constructor(options) {
|
|
10887
|
+
this.state = 0 /* Disconnected */;
|
|
10888
|
+
this.parser = null;
|
|
10889
|
+
// Game State
|
|
10890
|
+
this.serverProtocol = 0;
|
|
10891
|
+
this.serverCount = 0;
|
|
10892
|
+
this.gameDir = "";
|
|
10893
|
+
this.playerNum = 0;
|
|
10894
|
+
this.levelName = "";
|
|
10895
|
+
this.configStrings = /* @__PURE__ */ new Map();
|
|
10896
|
+
this.baselines = /* @__PURE__ */ new Map();
|
|
10897
|
+
this.challenge = 0;
|
|
10898
|
+
this.connectPacketCount = 0;
|
|
10899
|
+
this.connectPacketTime = 0;
|
|
10900
|
+
this.driver = new BrowserWebSocketNetDriver();
|
|
10901
|
+
this.options = options;
|
|
10902
|
+
this.driver.onMessage((data) => this.handleMessage(data));
|
|
10903
|
+
this.driver.onClose(() => this.handleDisconnect());
|
|
10904
|
+
this.driver.onError((err2) => console.error("Network Error:", err2));
|
|
10905
|
+
}
|
|
10906
|
+
async connect(url) {
|
|
10907
|
+
if (this.state !== 0 /* Disconnected */) {
|
|
10908
|
+
this.disconnect();
|
|
10909
|
+
}
|
|
10910
|
+
console.log(`Connecting to ${url}...`);
|
|
10911
|
+
this.state = 1 /* Connecting */;
|
|
10912
|
+
try {
|
|
10913
|
+
await this.driver.connect(url);
|
|
10914
|
+
console.log("WebSocket connected.");
|
|
10915
|
+
this.state = 2 /* Challenge */;
|
|
10916
|
+
this.sendChallenge();
|
|
10917
|
+
} catch (e) {
|
|
10918
|
+
console.error("Connection failed:", e);
|
|
10919
|
+
this.state = 0 /* Disconnected */;
|
|
10920
|
+
throw e;
|
|
10921
|
+
}
|
|
10922
|
+
}
|
|
10923
|
+
disconnect() {
|
|
10924
|
+
if (this.state === 0 /* Disconnected */) return;
|
|
10925
|
+
this.driver.disconnect();
|
|
10926
|
+
this.state = 0 /* Disconnected */;
|
|
10927
|
+
this.configStrings.clear();
|
|
10928
|
+
this.baselines.clear();
|
|
10929
|
+
}
|
|
10930
|
+
sendCommand(cmd) {
|
|
10931
|
+
if (this.state !== 5 /* Active */) return;
|
|
10932
|
+
const builder = new NetworkMessageBuilder();
|
|
10933
|
+
builder.writeByte(ClientCommand.nop);
|
|
10934
|
+
this.driver.send(builder.getData());
|
|
10935
|
+
}
|
|
10936
|
+
handleMessage(data) {
|
|
10937
|
+
let buffer = data.buffer;
|
|
10938
|
+
if (buffer instanceof SharedArrayBuffer) {
|
|
10939
|
+
const newBuffer = new ArrayBuffer(data.byteLength);
|
|
10940
|
+
new Uint8Array(newBuffer).set(data);
|
|
10941
|
+
buffer = newBuffer;
|
|
10942
|
+
}
|
|
10943
|
+
const stream = new BinaryStream2(buffer);
|
|
10944
|
+
const sequence = stream.readLong();
|
|
10945
|
+
const sequenceAck = stream.readLong();
|
|
10946
|
+
this.parser = new NetworkMessageParser(stream, this);
|
|
10947
|
+
this.parser.parseMessage();
|
|
10948
|
+
}
|
|
10949
|
+
handleDisconnect() {
|
|
10950
|
+
console.log("Disconnected from server.");
|
|
10951
|
+
this.state = 0 /* Disconnected */;
|
|
10952
|
+
}
|
|
10953
|
+
sendChallenge() {
|
|
10954
|
+
const builder = new NetworkMessageBuilder();
|
|
10955
|
+
builder.writeByte(ClientCommand.stringcmd);
|
|
10956
|
+
builder.writeString("getchallenge");
|
|
10957
|
+
this.driver.send(builder.getData());
|
|
10958
|
+
}
|
|
10959
|
+
sendConnect(challenge) {
|
|
10960
|
+
const builder = new NetworkMessageBuilder();
|
|
10961
|
+
builder.writeByte(ClientCommand.stringcmd);
|
|
10962
|
+
const userinfo = `\\name\\${this.options.username}\\model\\${this.options.model}\\skin\\${this.options.skin}\\hand\\${this.options.hand ?? 0}\\fov\\${this.options.fov ?? 90}`;
|
|
10963
|
+
builder.writeString(`connect ${PROTOCOL_VERSION_RERELEASE} ${challenge} ${userinfo}`);
|
|
10964
|
+
this.driver.send(builder.getData());
|
|
10965
|
+
}
|
|
10966
|
+
isConnected() {
|
|
10967
|
+
return this.state === 5 /* Active */;
|
|
10968
|
+
}
|
|
10969
|
+
// ==================================================================================
|
|
10970
|
+
// NetworkMessageHandler Implementation
|
|
10971
|
+
// ==================================================================================
|
|
10972
|
+
onServerData(protocol, serverCount, attractLoop, gameDir, playerNum, levelName) {
|
|
10973
|
+
console.log(`Server Data: Protocol ${protocol}, Level ${levelName}`);
|
|
10974
|
+
this.serverProtocol = protocol;
|
|
10975
|
+
this.serverCount = serverCount;
|
|
10976
|
+
this.gameDir = gameDir;
|
|
10977
|
+
this.playerNum = playerNum;
|
|
10978
|
+
this.levelName = levelName;
|
|
10979
|
+
this.state = 3 /* Connected */;
|
|
10980
|
+
const builder = new NetworkMessageBuilder();
|
|
10981
|
+
builder.writeByte(ClientCommand.stringcmd);
|
|
10982
|
+
builder.writeString("new");
|
|
10983
|
+
this.driver.send(builder.getData());
|
|
10984
|
+
this.state = 4 /* Loading */;
|
|
10985
|
+
}
|
|
10986
|
+
onConfigString(index, str3) {
|
|
10987
|
+
this.configStrings.set(index, str3);
|
|
10988
|
+
}
|
|
10989
|
+
onSpawnBaseline(entity) {
|
|
10990
|
+
this.baselines.set(entity.number, entity);
|
|
10991
|
+
}
|
|
10992
|
+
onStuffText(msg) {
|
|
10993
|
+
console.log(`Server StuffText: ${msg}`);
|
|
10994
|
+
if (msg.startsWith("precache")) {
|
|
10995
|
+
this.finishLoading();
|
|
10996
|
+
}
|
|
10997
|
+
if (msg.startsWith("challenge ")) {
|
|
10998
|
+
const parts = msg.split(" ");
|
|
10999
|
+
if (parts.length > 1) {
|
|
11000
|
+
this.challenge = parseInt(parts[1], 10);
|
|
11001
|
+
this.sendConnect(this.challenge);
|
|
11002
|
+
}
|
|
11003
|
+
}
|
|
11004
|
+
}
|
|
11005
|
+
finishLoading() {
|
|
11006
|
+
console.log("Finished loading, sending begin...");
|
|
11007
|
+
const builder = new NetworkMessageBuilder();
|
|
11008
|
+
builder.writeByte(ClientCommand.stringcmd);
|
|
11009
|
+
builder.writeString("begin");
|
|
11010
|
+
this.driver.send(builder.getData());
|
|
11011
|
+
this.state = 5 /* Active */;
|
|
11012
|
+
}
|
|
11013
|
+
// Stubs for other handlers
|
|
11014
|
+
onFrame(frame) {
|
|
11015
|
+
}
|
|
11016
|
+
onCenterPrint(msg) {
|
|
11017
|
+
}
|
|
11018
|
+
onPrint(level, msg) {
|
|
11019
|
+
}
|
|
11020
|
+
onSound(flags, soundNum, volume, attenuation, offset, ent, pos) {
|
|
11021
|
+
}
|
|
11022
|
+
onTempEntity(type, pos, pos2, dir, cnt, color, ent, srcEnt, destEnt) {
|
|
11023
|
+
}
|
|
11024
|
+
onLayout(layout) {
|
|
11025
|
+
}
|
|
11026
|
+
onInventory(inventory) {
|
|
11027
|
+
}
|
|
11028
|
+
onMuzzleFlash(ent, weapon) {
|
|
11029
|
+
}
|
|
11030
|
+
onMuzzleFlash2(ent, weapon) {
|
|
11031
|
+
}
|
|
11032
|
+
onDisconnect() {
|
|
11033
|
+
this.disconnect();
|
|
11034
|
+
}
|
|
11035
|
+
onReconnect() {
|
|
11036
|
+
}
|
|
11037
|
+
onDownload(size, percent, data) {
|
|
11038
|
+
}
|
|
11039
|
+
};
|
|
11040
|
+
|
|
10359
11041
|
// src/input/bindings.ts
|
|
10360
11042
|
var DEFAULT_BINDINGS = [
|
|
10361
11043
|
{ code: "KeyW", command: "+forward" },
|
|
@@ -10889,6 +11571,21 @@ function createClient(imports) {
|
|
|
10889
11571
|
};
|
|
10890
11572
|
const cgameImport = createCGameImport(imports, stateProvider);
|
|
10891
11573
|
const cg = (0, import_cgame2.GetCGameAPI)(cgameImport);
|
|
11574
|
+
const multiplayer = new MultiplayerConnection({
|
|
11575
|
+
get username() {
|
|
11576
|
+
return imports.host?.cvars?.get("name")?.string || "Player";
|
|
11577
|
+
},
|
|
11578
|
+
get model() {
|
|
11579
|
+
return imports.host?.cvars?.get("model")?.string || "male";
|
|
11580
|
+
},
|
|
11581
|
+
get skin() {
|
|
11582
|
+
return imports.host?.cvars?.get("skin")?.string || "grunt";
|
|
11583
|
+
},
|
|
11584
|
+
get fov() {
|
|
11585
|
+
return fovValue;
|
|
11586
|
+
}
|
|
11587
|
+
});
|
|
11588
|
+
const multiplayerFactory = new MultiplayerMenuFactory(menuSystem, multiplayer);
|
|
10892
11589
|
demoHandler.setCallbacks({
|
|
10893
11590
|
onCenterPrint: (msg) => cg.ParseCenterPrint(msg, 0, false),
|
|
10894
11591
|
onPrint: (level, msg) => cg.NotifyMessage(0, msg, false),
|
|
@@ -10951,6 +11648,22 @@ function createClient(imports) {
|
|
|
10951
11648
|
menuSystem.pushMenu(pauseMenuFactory.createPauseMenu());
|
|
10952
11649
|
}
|
|
10953
11650
|
}, "Toggle the main/pause menu");
|
|
11651
|
+
imports.host.commands.register("connect", (args) => {
|
|
11652
|
+
if (args.length < 1) {
|
|
11653
|
+
console.log("usage: connect <address>");
|
|
11654
|
+
return;
|
|
11655
|
+
}
|
|
11656
|
+
const address = args[0];
|
|
11657
|
+
console.log(`Connecting to ${address}...`);
|
|
11658
|
+
multiplayer.connect(address).catch((e) => {
|
|
11659
|
+
console.error("Failed to connect:", e);
|
|
11660
|
+
errorDialog.show("Connection Failed", e instanceof Error ? e.message : "Unknown error");
|
|
11661
|
+
});
|
|
11662
|
+
}, "Connect to a multiplayer server");
|
|
11663
|
+
imports.host.commands.register("disconnect", () => {
|
|
11664
|
+
multiplayer.disconnect();
|
|
11665
|
+
console.log("Disconnected.");
|
|
11666
|
+
}, "Disconnect from server");
|
|
10954
11667
|
if (imports.host.cvars) {
|
|
10955
11668
|
imports.host.cvars.register({
|
|
10956
11669
|
name: "fov",
|
|
@@ -11005,6 +11718,9 @@ function createClient(imports) {
|
|
|
11005
11718
|
predict(command) {
|
|
11006
11719
|
if (menuSystem.isActive()) {
|
|
11007
11720
|
}
|
|
11721
|
+
if (multiplayer.isConnected()) {
|
|
11722
|
+
multiplayer.sendCommand(command);
|
|
11723
|
+
}
|
|
11008
11724
|
return prediction.enqueueCommand(command);
|
|
11009
11725
|
},
|
|
11010
11726
|
handleInput(key, down) {
|
|
@@ -11069,6 +11785,7 @@ function createClient(imports) {
|
|
|
11069
11785
|
...options,
|
|
11070
11786
|
optionsFactory: optsFactory,
|
|
11071
11787
|
mapsFactory,
|
|
11788
|
+
multiplayerFactory,
|
|
11072
11789
|
onSetDifficulty: (skill) => {
|
|
11073
11790
|
if (imports.host?.cvars) {
|
|
11074
11791
|
imports.host.cvars.setValue("skill", skill.toString());
|
|
@@ -11274,6 +11991,7 @@ function createClient(imports) {
|
|
|
11274
11991
|
cg.ParseConfigString(index, value);
|
|
11275
11992
|
},
|
|
11276
11993
|
demoHandler,
|
|
11994
|
+
multiplayer,
|
|
11277
11995
|
configStrings
|
|
11278
11996
|
};
|
|
11279
11997
|
return clientExports;
|