| 1 | |
| 2 | /** |
| 3 | * |
| 4 | * @file player.cpp |
| 5 | * |
| 6 | * Part of the OpenJazz project |
| 7 | * |
| 8 | * @par History: |
| 9 | * - 23rd August 2005: Created level.c |
| 10 | * - 1st January 2006: Created events.c from parts of level.c |
| 11 | * - 3rd February 2009: Renamed events.c to events.cpp and level.c to level.cpp, |
| 12 | * created player.cpp |
| 13 | * - 5th February 2009: Added parts of events.cpp and level.cpp to player.cpp |
| 14 | * - 19th March 2009: Created sprite.cpp from parts of event.cpp and player.cpp |
| 15 | * - 18th July 2009: Created playerframe.cpp from parts of player.cpp |
| 16 | * |
| 17 | * @par Licence: |
| 18 | * Copyright (c) 2005-2012 AJ Thomson |
| 19 | * |
| 20 | * OpenJazz is distributed under the terms of |
| 21 | * the GNU General Public License, version 2.0 |
| 22 | * |
| 23 | * @par Description: |
| 24 | * Deals with the creation and destruction of players, and their interactions |
| 25 | * with other objects. |
| 26 | * |
| 27 | */ |
| 28 | |
| 29 | |
| 30 | #include "jj1/bonuslevel/jj1bonuslevelplayer.h"cxx . . $ `<file>/src/jj1/bonuslevel/jj1bonuslevelplayer.h`/ |
| 31 | #include "jj1/level/jj1levelplayer.h"cxx . . $ `<file>/src/jj1/level/jj1levelplayer.h`/ |
| 32 | #ifdef ENABLE_JJ2 |
| 33 | #include "jj2/level/jj2levelplayer.h" |
| 34 | #endif |
| 35 | #include "level/levelplayer.h"cxx . . $ `<file>/src/level/levelplayer.h`/ |
| 36 | |
| 37 | #include "game/game.h"cxx . . $ `<file>/src/game/game.h`/ |
| 38 | #include "io/controls.h"cxx . . $ `<file>/src/io/controls.h`/ |
| 39 | #include "util.h"cxx . . $ `<file>/src/util.h`/ |
| 40 | |
| 41 | #include <string.h> |
| 42 | #include <cassert> |
| 43 | |
| 44 | |
| 45 | /** |
| 46 | * Create the player. |
| 47 | */ |
| 48 | Playercxx . . $ Player#::Playercxx . . $ Player#Player(49f6e7a06ebc5aa8). () { |
| 49 | |
| 50 | levelPlayercxx . . $ Player#levelPlayer. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 51 | levelPlayerTypecxx . . $ Player#levelPlayerType. = LT_JJ1cxx . . $ LT_JJ1.; |
| 52 | namecxx . . $ Player#name. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 53 | |
| 54 | } |
| 55 | |
| 56 | |
| 57 | /** |
| 58 | * Delete the player. |
| 59 | */ |
| 60 | Playercxx . . $ Player#::~cxx . . $ Player#`~Player`(49f6e7a06ebc5aa8).Playercxx . . $ Player# () { |
| 61 | |
| 62 | deinitcxx . . $ Player#deinit(49f6e7a06ebc5aa8).(); |
| 63 | |
| 64 | } |
| 65 | |
| 66 | |
| 67 | /** |
| 68 | * Initialise player data. |
| 69 | * |
| 70 | * Deinitialise any existing player data, assign properties and initial values. |
| 71 | * |
| 72 | * @param owner The current game |
| 73 | * @param playerName Name (displayed in multiplayer games) |
| 74 | * @param playerCols Colours (only used in multiplayer games) |
| 75 | * @param newTeam Team (in multiplayer games) |
| 76 | */ |
| 77 | void Playercxx . . $ Player#::initcxx . . $ Player#init(eadcf6f4775e9cbb). (Gamecxx . . $ Game#* owner, char *playerName, unsigned char *playerCols, unsigned char newTeam) { |
| 78 | |
| 79 | // Clear existing player |
| 80 | deinitcxx . . $ Player#deinit(49f6e7a06ebc5aa8).(); |
| 81 | |
| 82 | // Assign owner |
| 83 | gamecxx . . $ Player#game. = owner; |
| 84 | |
| 85 | // Assign name |
| 86 | namecxx . . $ Player#name. = createStringcxx . . $ createString(a8b8e32347182212).(playerName); |
| 87 | |
| 88 | // Assign initial values |
| 89 | scorecxx . . $ Player#score. = 0; |
| 90 | livescxx . . $ Player#lives. = 3; |
| 91 | ammoTypecxx . . $ Player#ammoType. = -1; |
| 92 | ammocxx . . $ Player#ammo.[0] = 0; |
| 93 | ammocxx . . $ Player#ammo.[1] = 0; |
| 94 | ammocxx . . $ Player#ammo.[2] = 0; |
| 95 | ammocxx . . $ Player#ammo.[3] = 0; |
| 96 | ammocxx . . $ Player#ammo.[4] = 0; |
| 97 | fireSpeedcxx . . $ Player#fireSpeed. = 0; |
| 98 | flockSizecxx . . $ Player#flockSize. = 0; |
| 99 | teamcxx . . $ Player#team. = newTeam; |
| 100 | teamScorecxx . . $ Player#teamScore. = 0; |
| 101 | |
| 102 | if (playerCols) { |
| 103 | |
| 104 | memcpy(colscxx . . $ Player#cols., playerCols, PCOLOURScxx . . $ `src/player/player.h:48:9`!); |
| 105 | |
| 106 | } else { |
| 107 | |
| 108 | colscxx . . $ Player#cols.[0] = CHAR_FURcxx . . $ `src/player/player.h:39:9`!; |
| 109 | colscxx . . $ Player#cols.[1] = CHAR_BANDcxx . . $ `src/player/player.h:40:9`!; |
| 110 | colscxx . . $ Player#cols.[2] = CHAR_GUNcxx . . $ `src/player/player.h:41:9`!; |
| 111 | colscxx . . $ Player#cols.[3] = CHAR_WBANDcxx . . $ `src/player/player.h:42:9`!; |
| 112 | |
| 113 | } |
| 114 | |
| 115 | } |
| 116 | |
| 117 | |
| 118 | /** |
| 119 | * Deinitialise player data. |
| 120 | */ |
| 121 | void Playercxx . . $ Player#::deinitcxx . . $ Player#deinit(49f6e7a06ebc5aa8). () { |
| 122 | |
| 123 | if (levelPlayercxx . . $ Player#levelPlayer.) delete levelPlayercxx . . $ Player#levelPlayer.; |
| 124 | levelPlayercxx . . $ Player#levelPlayer. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 125 | |
| 126 | if (namecxx . . $ Player#name.) delete[] namecxx . . $ Player#name.; |
| 127 | namecxx . . $ Player#name. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 128 | |
| 129 | } |
| 130 | |
| 131 | |
| 132 | /** |
| 133 | * Discard all the player's ammo. |
| 134 | */ |
| 135 | void Playercxx . . $ Player#::clearAmmocxx . . $ Player#clearAmmo(49f6e7a06ebc5aa8). () { |
| 136 | |
| 137 | int type; |
| 138 | |
| 139 | for (type = 0; type < 5; type++) ammocxx . . $ Player#ammo.[type] = 0; |
| 140 | |
| 141 | ammoTypecxx . . $ Player#ammoType. = -1; |
| 142 | fireSpeedcxx . . $ Player#fireSpeed. = 0; |
| 143 | |
| 144 | } |
| 145 | |
| 146 | |
| 147 | /** |
| 148 | * Reset the player's current level player. |
| 149 | * |
| 150 | * @param x The level player's new grid x-coordinate |
| 151 | * @param y The level player's new grid y-coordinate |
| 152 | */ |
| 153 | void Playercxx . . $ Player#::resetcxx . . $ Player#reset(3e454b8ccf442868). (int x, int y) { |
| 154 | |
| 155 | levelPlayercxx . . $ Player#levelPlayer.->resetcxx . . $ LevelPlayer#reset(3e454b8ccf442868).(x, y); |
| 156 | |
| 157 | } |
| 158 | |
| 159 | |
| 160 | /** |
| 161 | * Create a new level player for the player (and delete any existing one). |
| 162 | * |
| 163 | * @param levelType The type of level for which to create a level player |
| 164 | * @param anims New level player animations |
| 165 | * @param flippedAnims New level player flipped animations |
| 166 | * @param x The level player's new grid x-coordinate |
| 167 | * @param y The level player's new grid y-coordinate |
| 168 | */ |
| 169 | void Playercxx . . $ Player#::createLevelPlayercxx . . $ Player#createLevelPlayer(27ab3ccb3efab72). (LevelTypecxx . . $ LevelType# levelType, Animcxx . . $ Anim#** anims, |
| 170 | Animcxx . . $ Anim#** flippedAnims, unsigned char x, unsigned char y) { |
| 171 | |
| 172 | #ifndef ENABLE_JJ2 |
| 173 | (void)flippedAnims; |
| 174 | #endif |
| 175 | |
| 176 | if (levelPlayercxx . . $ Player#levelPlayer.) { |
| 177 | |
| 178 | flockSizecxx . . $ Player#flockSize. = levelPlayercxx . . $ Player#levelPlayer.->countBirdscxx . . $ LevelPlayer#countBirds(b126dc7c1de90089).(); |
| 179 | delete levelPlayercxx . . $ Player#levelPlayer.; |
| 180 | |
| 181 | } |
| 182 | |
| 183 | levelPlayerTypecxx . . $ Player#levelPlayerType. = levelType; |
| 184 | |
| 185 | switch (levelType) { |
| 186 | |
| 187 | case LT_JJ1cxx . . $ LT_JJ1.: |
| 188 | |
| 189 | levelPlayercxx . . $ Player#levelPlayer. = new JJ1LevelPlayercxx . . $ JJ1LevelPlayer#JJ1LevelPlayer(5af78e539686a824).(this, anims, x, y, flockSizecxx . . $ Player#flockSize.); |
| 190 | |
| 191 | break; |
| 192 | |
| 193 | case LT_JJ1BONUScxx . . $ LT_JJ1BONUS.: |
| 194 | |
| 195 | levelPlayercxx . . $ Player#levelPlayer. = new JJ1BonusLevelPlayercxx . . $ JJ1BonusLevelPlayer#JJ1BonusLevelPlayer(5af78e539686a824).(this, anims, x, y, flockSizecxx . . $ Player#flockSize.); |
| 196 | |
| 197 | break; |
| 198 | |
| 199 | #ifdef ENABLE_JJ2 |
| 200 | |
| 201 | case LT_JJ2: |
| 202 | |
| 203 | levelPlayer = new JJ2LevelPlayer(this, anims, flippedAnims, x, y, flockSize); |
| 204 | |
| 205 | break; |
| 206 | |
| 207 | #endif |
| 208 | |
| 209 | } |
| 210 | |
| 211 | for (int i = 0; i < PCONTROLScxx . . $ `src/player/player.h:45:9`!; i++) pcontrolscxx . . $ Player#pcontrols.[i] = false; |
| 212 | |
| 213 | } |
| 214 | |
| 215 | |
| 216 | /** |
| 217 | * Get the player's level player. |
| 218 | * |
| 219 | * @return The level player |
| 220 | */ |
| 221 | LevelPlayercxx . . $ LevelPlayer#* Playercxx . . $ Player#::getLevelPlayercxx . . $ Player#getLevelPlayer(e55247ee3168a607). () { |
| 222 | |
| 223 | return levelPlayercxx . . $ Player#levelPlayer.; |
| 224 | |
| 225 | } |
| 226 | |
| 227 | |
| 228 | /** |
| 229 | * Get the player's colours. |
| 230 | * |
| 231 | * @return The player's colours |
| 232 | */ |
| 233 | unsigned char * Playercxx . . $ Player#::getColscxx . . $ Player#getCols(37d8967d10cb1e7b). () { |
| 234 | |
| 235 | return colscxx . . $ Player#cols.; |
| 236 | |
| 237 | } |
| 238 | |
| 239 | |
| 240 | /** |
| 241 | * Get the player's name. |
| 242 | * |
| 243 | * @return The player's name |
| 244 | */ |
| 245 | char * Playercxx . . $ Player#::getNamecxx . . $ Player#getName(41208ce6ca65dd58). () { |
| 246 | |
| 247 | return namecxx . . $ Player#name.; |
| 248 | |
| 249 | } |
| 250 | |
| 251 | |
| 252 | /** |
| 253 | * Get the player's JJ1 bonus level player. |
| 254 | * |
| 255 | * @return The JJ1 bonus level player |
| 256 | */ |
| 257 | JJ1BonusLevelPlayercxx . . $ JJ1BonusLevelPlayer#* Playercxx . . $ Player#::getJJ1BonusLevelPlayercxx . . $ Player#getJJ1BonusLevelPlayer(5b714c54c39cd209). () { |
| 258 | |
| 259 | assertcxx . . $ `<external>/4398592474888995393/assert.h:102:11`!(levelPlayerType == LT_JJ1BONUS); |
| 260 | |
| 261 | return static_cast<JJ1BonusLevelPlayercxx . . $ JJ1BonusLevelPlayer#*>(levelPlayercxx . . $ Player#levelPlayer.); |
| 262 | |
| 263 | } |
| 264 | |
| 265 | |
| 266 | /** |
| 267 | * Get the player's JJ1 level player. |
| 268 | * |
| 269 | * @return The JJ1 level player |
| 270 | */ |
| 271 | JJ1LevelPlayercxx . . $ JJ1LevelPlayer#* Playercxx . . $ Player#::getJJ1LevelPlayercxx . . $ Player#getJJ1LevelPlayer(cf23ec4c0d6db922). () { |
| 272 | |
| 273 | assertcxx . . $ `<external>/4398592474888995393/assert.h:102:11`!(levelPlayerType == LT_JJ1); |
| 274 | |
| 275 | return static_cast<JJ1LevelPlayercxx . . $ JJ1LevelPlayer#*>(levelPlayercxx . . $ Player#levelPlayer.); |
| 276 | |
| 277 | } |
| 278 | |
| 279 | #ifdef ENABLE_JJ2 |
| 280 | |
| 281 | /** |
| 282 | * Get the player's JJ2 level player. |
| 283 | * |
| 284 | * @return The JJ2 level player |
| 285 | */ |
| 286 | JJ2LevelPlayer* Player::getJJ2LevelPlayer () { |
| 287 | |
| 288 | assert(levelPlayerType == LT_JJ2); |
| 289 | |
| 290 | return static_cast<JJ2LevelPlayer*>(levelPlayer); |
| 291 | |
| 292 | } |
| 293 | |
| 294 | #endif |
| 295 | |
| 296 | |
| 297 | /** |
| 298 | * Set the state of the specified control. |
| 299 | * |
| 300 | * @param control Affected control |
| 301 | * @param state New state |
| 302 | */ |
| 303 | void Playercxx . . $ Player#::setControlcxx . . $ Player#setControl(918ebd27a9ddbad3). (int control, bool state) { |
| 304 | |
| 305 | pcontrolscxx . . $ Player#pcontrols.[control] = state; |
| 306 | |
| 307 | } |
| 308 | |
| 309 | |
| 310 | /** |
| 311 | * Get the state of the specified control. |
| 312 | * |
| 313 | * @param control The control |
| 314 | * |
| 315 | * @return State |
| 316 | */ |
| 317 | bool Playercxx . . $ Player#::getControlcxx . . $ Player#getControl(83c267b20bac841a). (int control) { |
| 318 | |
| 319 | return pcontrolscxx . . $ Player#pcontrols.[control]; |
| 320 | |
| 321 | } |
| 322 | |
| 323 | |
| 324 | /** |
| 325 | * Add to the player's total score. |
| 326 | * |
| 327 | * @param addedScore The amount to be added |
| 328 | */ |
| 329 | void Playercxx . . $ Player#::addScorecxx . . $ Player#addScore(d4f767463ce0a6b3). (int addedScore) { |
| 330 | |
| 331 | scorecxx . . $ Player#score. += addedScore; |
| 332 | |
| 333 | } |
| 334 | |
| 335 | |
| 336 | /** |
| 337 | * Get the player's score. |
| 338 | */ |
| 339 | int Playercxx . . $ Player#::getScorecxx . . $ Player#getScore(b126dc7c1de90089). () { |
| 340 | |
| 341 | return scorecxx . . $ Player#score.; |
| 342 | |
| 343 | } |
| 344 | |
| 345 | |
| 346 | /** |
| 347 | * Add an extra life to the player. |
| 348 | */ |
| 349 | void Playercxx . . $ Player#::addLifecxx . . $ Player#addLife(49f6e7a06ebc5aa8). () { |
| 350 | |
| 351 | if (livescxx . . $ Player#lives. < 99) livescxx . . $ Player#lives.++; |
| 352 | |
| 353 | } |
| 354 | |
| 355 | |
| 356 | /** |
| 357 | * Get the number of extra lives. |
| 358 | * |
| 359 | * @return Number of extra lives |
| 360 | */ |
| 361 | int Playercxx . . $ Player#::getLivescxx . . $ Player#getLives(b126dc7c1de90089). () { |
| 362 | |
| 363 | return livescxx . . $ Player#lives.; |
| 364 | |
| 365 | } |
| 366 | |
| 367 | |
| 368 | /** |
| 369 | * Add ammo to the player's arsenal. |
| 370 | * |
| 371 | * @param type Type of ammo |
| 372 | * @param amount Amount of ammo to add |
| 373 | */ |
| 374 | void Playercxx . . $ Player#::addAmmocxx . . $ Player#addAmmo(3e454b8ccf442868). (int type, int amount) { |
| 375 | |
| 376 | if (!ammocxx . . $ Player#ammo.[type]) ammoTypecxx . . $ Player#ammoType. = type; |
| 377 | ammocxx . . $ Player#ammo.[type] += amount; |
| 378 | |
| 379 | } |
| 380 | |
| 381 | |
| 382 | /** |
| 383 | * Get the current type of ammo. |
| 384 | * |
| 385 | * @return The type of ammo |
| 386 | */ |
| 387 | int Playercxx . . $ Player#::getAmmoTypecxx . . $ Player#getAmmoType(b126dc7c1de90089). () { |
| 388 | |
| 389 | return ammoTypecxx . . $ Player#ammoType.; |
| 390 | |
| 391 | } |
| 392 | |
| 393 | |
| 394 | /** |
| 395 | * Get the total amount of ammo of the current type. |
| 396 | * |
| 397 | * @return The amount of ammo |
| 398 | */ |
| 399 | int Playercxx . . $ Player#::getAmmocxx . . $ Player#getAmmo(b126dc7c1de90089). () { |
| 400 | |
| 401 | return ammocxx . . $ Player#ammo.[ammoTypecxx . . $ Player#ammoType.]; |
| 402 | |
| 403 | } |
| 404 | |
| 405 | |
| 406 | /** |
| 407 | * Get the player's team |
| 408 | * |
| 409 | * @return Team number |
| 410 | */ |
| 411 | unsigned char Playercxx . . $ Player#::getTeamcxx . . $ Player#getTeam(7c4be072098b358f). () { |
| 412 | |
| 413 | return teamcxx . . $ Player#team.; |
| 414 | |
| 415 | } |
| 416 | |
| 417 | |
| 418 | /** |
| 419 | * Deal with bullet collisions. |
| 420 | * |
| 421 | * @param source Player that fired the bullet (NULL if an event) |
| 422 | * |
| 423 | * @return Whether or not the hit was successful |
| 424 | */ |
| 425 | bool Playercxx . . $ Player#::hitcxx . . $ Player#hit(642b3750baa38d6c). (Playercxx . . $ Player# *source) { |
| 426 | |
| 427 | return gamecxx . . $ Player#game.->getModecxx . . $ Game#getMode(b2ac8a9286443acb).()->hitcxx . . $ GameMode#hit(e1486006e22d1cdc).(source, this); |
| 428 | |
| 429 | } |
| 430 | |
| 431 | |
| 432 | /** |
| 433 | * Kill the player. |
| 434 | * |
| 435 | * @param source Player responsible for the kill (NULL if due to an event or time) |
| 436 | * |
| 437 | * @return Whether or not the kill was successful |
| 438 | */ |
| 439 | bool Playercxx . . $ Player#::killcxx . . $ Player#kill(642b3750baa38d6c). (Playercxx . . $ Player# *source) { |
| 440 | |
| 441 | return gamecxx . . $ Player#game.->getModecxx . . $ Game#getMode(b2ac8a9286443acb).()->killcxx . . $ GameMode#kill(ed28dcf7b803e269).(gamecxx . . $ Player#game., source, this); |
| 442 | |
| 443 | } |
| 444 | |
| 445 | |
| 446 | /** |
| 447 | * Set the checkpoint |
| 448 | * |
| 449 | * @param gridX X-coordinate (in tiles) of the checkpoint |
| 450 | * @param gridY Y-coordinate (in tiles) of the checkpoint |
| 451 | */ |
| 452 | void Playercxx . . $ Player#::setCheckpointcxx . . $ Player#setCheckpoint(3e454b8ccf442868). (int gridX, int gridY) { |
| 453 | |
| 454 | gamecxx . . $ Player#game.->setCheckpointcxx . . $ Game#setCheckpoint(3e454b8ccf442868).(gridX, gridY); |
| 455 | |
| 456 | } |
| 457 | |
| 458 | |
| 459 | /** |
| 460 | * Outcome of level being completed |
| 461 | * |
| 462 | * @param gridX X-coordinate (in tiles) of finishing position |
| 463 | * @param gridY Y-coordinate (in tiles) of finishing position |
| 464 | * |
| 465 | * @return Whether or not the level should end |
| 466 | */ |
| 467 | bool Playercxx . . $ Player#::endOfLevelcxx . . $ Player#endOfLevel(cf9ef193275fa6d8). (int gridX, int gridY) { |
| 468 | |
| 469 | return gamecxx . . $ Player#game.->getModecxx . . $ Game#getMode(b2ac8a9286443acb).()->endOfLevelcxx . . $ GameMode#endOfLevel(58252f3afe5a5e7).(gamecxx . . $ Player#game., this, gridX, gridY); |
| 470 | |
| 471 | } |
| 472 | |
| 473 | |
| 474 | /** |
| 475 | * Copy data to be sent to clients/server |
| 476 | */ |
| 477 | void Playercxx . . $ Player#::sendcxx . . $ Player#send(f25546b61a629de7). (unsigned char *buffer) { |
| 478 | |
| 479 | buffer[3] = pcontrolscxx . . $ Player#pcontrols.[C_UPcxx . . $ `src/io/controls.h:30:9`!]; |
| 480 | buffer[4] = pcontrolscxx . . $ Player#pcontrols.[C_DOWNcxx . . $ `src/io/controls.h:31:9`!]; |
| 481 | buffer[5] = pcontrolscxx . . $ Player#pcontrols.[C_LEFTcxx . . $ `src/io/controls.h:32:9`!]; |
| 482 | buffer[6] = pcontrolscxx . . $ Player#pcontrols.[C_RIGHTcxx . . $ `src/io/controls.h:33:9`!]; |
| 483 | buffer[7] = pcontrolscxx . . $ Player#pcontrols.[C_JUMPcxx . . $ `src/io/controls.h:34:9`!]; |
| 484 | buffer[8] = pcontrolscxx . . $ Player#pcontrols.[C_FIREcxx . . $ `src/io/controls.h:36:9`!]; |
| 485 | buffer[10] = ammocxx . . $ Player#ammo.[0] >> 8; |
| 486 | buffer[11] = ammocxx . . $ Player#ammo.[0] & 255; |
| 487 | buffer[12] = ammocxx . . $ Player#ammo.[1] >> 8; |
| 488 | buffer[13] = ammocxx . . $ Player#ammo.[1] & 255; |
| 489 | buffer[14] = ammocxx . . $ Player#ammo.[2] >> 8; |
| 490 | buffer[15] = ammocxx . . $ Player#ammo.[2] & 255; |
| 491 | buffer[16] = ammocxx . . $ Player#ammo.[3] >> 8; |
| 492 | buffer[17] = ammocxx . . $ Player#ammo.[3] & 255; |
| 493 | buffer[18] = ammoTypecxx . . $ Player#ammoType. + 1; |
| 494 | buffer[19] = scorecxx . . $ Player#score. >> 24; |
| 495 | buffer[20] = (scorecxx . . $ Player#score. >> 16) & 255; |
| 496 | buffer[21] = (scorecxx . . $ Player#score. >> 8) & 255; |
| 497 | buffer[22] = scorecxx . . $ Player#score. & 255; |
| 498 | buffer[24] = livescxx . . $ Player#lives.; |
| 499 | buffer[28] = fireSpeedcxx . . $ Player#fireSpeed.; |
| 500 | buffer[45] = pcontrolscxx . . $ Player#pcontrols.[C_SWIMcxx . . $ `src/io/controls.h:35:9`!]; |
| 501 | |
| 502 | if (levelPlayercxx . . $ Player#levelPlayer.) levelPlayercxx . . $ Player#levelPlayer.->sendcxx . . $ LevelPlayer#send(f25546b61a629de7).(buffer); |
| 503 | |
| 504 | } |
| 505 | |
| 506 | |
| 507 | /** |
| 508 | * Interpret data received from client/server |
| 509 | */ |
| 510 | void Playercxx . . $ Player#::receivecxx . . $ Player#receive(f25546b61a629de7). (unsigned char *buffer) { |
| 511 | |
| 512 | if (buffer[1] == MT_P_TEMPcxx . . $ `src/game/game.h:60:9`!) { |
| 513 | |
| 514 | pcontrolscxx . . $ Player#pcontrols.[C_UPcxx . . $ `src/io/controls.h:30:9`!] = buffer[3]; |
| 515 | pcontrolscxx . . $ Player#pcontrols.[C_DOWNcxx . . $ `src/io/controls.h:31:9`!] = buffer[4]; |
| 516 | pcontrolscxx . . $ Player#pcontrols.[C_LEFTcxx . . $ `src/io/controls.h:32:9`!] = buffer[5]; |
| 517 | pcontrolscxx . . $ Player#pcontrols.[C_RIGHTcxx . . $ `src/io/controls.h:33:9`!] = buffer[6]; |
| 518 | pcontrolscxx . . $ Player#pcontrols.[C_JUMPcxx . . $ `src/io/controls.h:34:9`!] = buffer[7]; |
| 519 | pcontrolscxx . . $ Player#pcontrols.[C_SWIMcxx . . $ `src/io/controls.h:35:9`!] = buffer[45]; |
| 520 | pcontrolscxx . . $ Player#pcontrols.[C_FIREcxx . . $ `src/io/controls.h:36:9`!] = buffer[8]; |
| 521 | pcontrolscxx . . $ Player#pcontrols.[C_CHANGEcxx . . $ `src/io/controls.h:37:9`!] = false; |
| 522 | flockSizecxx . . $ Player#flockSize. = buffer[9]; |
| 523 | ammocxx . . $ Player#ammo.[0] = (buffer[10] << 8) + buffer[11]; |
| 524 | ammocxx . . $ Player#ammo.[1] = (buffer[12] << 8) + buffer[13]; |
| 525 | ammocxx . . $ Player#ammo.[2] = (buffer[14] << 8) + buffer[15]; |
| 526 | ammocxx . . $ Player#ammo.[3] = (buffer[16] << 8) + buffer[17]; |
| 527 | ammoTypecxx . . $ Player#ammoType. = buffer[18] - 1; |
| 528 | scorecxx . . $ Player#score. = (buffer[19] << 24) + (buffer[20] << 16) + (buffer[21] << 8) + buffer[22]; |
| 529 | livescxx . . $ Player#lives. = buffer[24]; |
| 530 | fireSpeedcxx . . $ Player#fireSpeed. = buffer[28]; |
| 531 | |
| 532 | } |
| 533 | |
| 534 | if (levelPlayercxx . . $ Player#levelPlayer.) levelPlayercxx . . $ Player#levelPlayer.->receivecxx . . $ LevelPlayer#receive(f25546b61a629de7).(buffer); |
| 535 | |
| 536 | } |