Differences From Artifact [be4039eb8e]:
- File
src/clients2c.m
— part of check-in
[304230c1e1]
at
2025-03-23 21:52:54
on branch trunk
— Avoid pointless pointers
Passing OFVector3D by reference is annoying and is worse at passing via registers. (user: js, size: 9143) [annotate] [blame] [check-ins using]
To Artifact [ffe8228e75]:
- File src/clients2c.m — part of check-in [5b7b7d2fc5] at 2025-03-24 22:14:24 on branch trunk — Convert player into a class (user: js, size: 9323) [annotate] [blame] [check-ins using]
1 2 3 4 5 6 7 8 9 10 11 12 13 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | + | // client processing of the incoming network stream #include "cube.h" #import "DynamicEntity.h" #import "Entity.h" #import "Player.h" extern int clientnum; extern bool c2sinit, senditemstoserver; extern OFString *toservermap; extern OFString *clientpassword; void |
︙ | |||
33 34 35 36 37 38 39 40 41 42 43 44 45 46 | 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | + | // update the position of other clients in the game in our world // don't care if he's in the scenery or other players, // just don't overlap with our client void updatepos(DynamicEntity *d) { Player *player1 = Player.player1; const float r = player1.radius + d.radius; const float dx = player1.origin.x - d.origin.x; const float dy = player1.origin.y - d.origin.y; const float dz = player1.origin.z - d.origin.z; const float rz = player1.aboveEye + d.eyeHeight; const float fx = (float)fabs(dx), fy = (float)fabs(dy), fz = (float)fabs(dz); |
︙ | |||
178 179 180 181 182 183 184 185 | 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | + - + - + - + - + - - + + | getalias(nextmapalias); // look up map in the cycle changemap(map != nil ? map : getclientmap()); break; } // another client either connected or changed name/team case SV_INITC2S: { Player *d_ = (Player *)d; sgetstr(); |
︙ | |||
227 228 229 230 231 232 233 | 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 | - + + - + - + - + - + - - + + - + - + - + | } case SV_DAMAGE: { int target = getint(&p); int damage = getint(&p); int ls = getint(&p); if (target == clientnum) { |
︙ | |||
291 292 293 294 295 296 297 | 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 | - + | OFVector3D v = OFMakeVector3D(ents[i].x, ents[i].y, ents[i].z); playsound(S_ITEMSPAWN, &v); break; } // server acknowledges that I picked up this item case SV_ITEMACC: |
︙ | |||
357 358 359 360 361 362 363 | 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 | - - + + | case SV_PING: getint(&p); break; case SV_PONG: addmsg(0, 2, SV_CLIENTPING, |
︙ |