| 1 | |
| 2 | /** |
| 3 | * |
| 4 | * @file jj1level.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 | * - 22nd July 2008: Created levelload.c from parts of level.c |
| 12 | * - 3rd February 2009: Renamed level.c to level.cpp |
| 13 | * - 5th February 2009: Added parts of events.cpp and level.cpp to player.cpp |
| 14 | * - 9th March 2009: Created game.cpp from parts of menu.cpp and level.cpp |
| 15 | * - 18th July 2009: Created demolevel.cpp from parts of level.cpp and |
| 16 | * levelload.cpp |
| 17 | * - 19th July 2009: Created levelframe.cpp from parts of level.cpp |
| 18 | * - 19th July 2009: Added parts of levelload.cpp to level.cpp |
| 19 | * - 30th March 2010: Created baselevel.cpp from parts of level.cpp and |
| 20 | * levelframe.cpp |
| 21 | * - 29th June 2010: Created jj2level.cpp from parts of level.cpp |
| 22 | * - 1st August 2012: Renamed level.cpp to jj1level.cpp |
| 23 | * |
| 24 | * @par Licence: |
| 25 | * Copyright (c) 2005-2017 AJ Thomson |
| 26 | * Copyright (c) 2015-2024 Carsten Teibes |
| 27 | * |
| 28 | * OpenJazz is distributed under the terms of |
| 29 | * the GNU General Public License, version 2.0 |
| 30 | * |
| 31 | * @par Description: |
| 32 | * Deals with the creating, playing and freeing of levels. |
| 33 | * |
| 34 | */ |
| 35 | |
| 36 | |
| 37 | #include "jj1bullet.h"cxx . . $ `<file>/src/jj1/level/jj1bullet.h`/ |
| 38 | #include "event/jj1event.h"cxx . . $ `<file>/src/jj1/level/event/jj1event.h`/ |
| 39 | #include "jj1level.h"cxx . . $ `<file>/src/jj1/level/jj1level.h`/ |
| 40 | #include "jj1levelplayer.h"cxx . . $ `<file>/src/jj1/level/jj1levelplayer.h`/ |
| 41 | #include "jj1/jj1episodeutils.h"cxx . . $ `<file>/src/jj1/jj1episodeutils.h`/ |
| 42 | |
| 43 | #include "game/game.h"cxx . . $ `<file>/src/game/game.h`/ |
| 44 | #include "game/gamemode.h"cxx . . $ `<file>/src/game/gamemode.h`/ |
| 45 | #include "io/controls.h"cxx . . $ `<file>/src/io/controls.h`/ |
| 46 | #include "io/file.h"cxx . . $ `<file>/src/io/file.h`/ |
| 47 | #include "io/gfx/font.h"cxx . . $ `<file>/src/io/gfx/font.h`/ |
| 48 | #include "io/gfx/paletteeffects.h"cxx . . $ `<file>/src/io/gfx/paletteeffects.h`/ |
| 49 | #include "io/gfx/sprite.h"cxx . . $ `<file>/src/io/gfx/sprite.h`/ |
| 50 | #include "io/gfx/video.h"cxx . . $ `<file>/src/io/gfx/video.h`/ |
| 51 | #include "io/sound.h"cxx . . $ `<file>/src/io/sound.h`/ |
| 52 | #include "io/log.h"cxx . . $ `<file>/src/io/log.h`/ |
| 53 | #include "util.h"cxx . . $ `<file>/src/util.h`/ |
| 54 | |
| 55 | #include <string.h> |
| 56 | |
| 57 | |
| 58 | /** |
| 59 | * Base constructor for JJ1DemoLevel sub-class. |
| 60 | * |
| 61 | * @param owner The current game |
| 62 | */ |
| 63 | JJ1Levelcxx . . $ JJ1Level#::JJ1Levelcxx . . $ JJ1Level#JJ1Level(920e21dac2e7a81). (Gamecxx . . $ Game#* owner) : Levelcxx . . $ Level#(owner) { |
| 64 | tileSetcxx . . $ JJ1Level#tileSet. = panelcxx . . $ JJ1Level#panel. = nullptr; |
| 65 | for (int i = 0; i < 6; i++) |
| 66 | panelAmmocxx . . $ JJ1Level#panelAmmo.[i] = nullptr; |
| 67 | for (int i = 0; i < 2; i++) |
| 68 | panelBGcxx . . $ JJ1Level#panelBG.[i] = nullptr; |
| 69 | eventscxx . . $ JJ1Level#events. = nullptr; |
| 70 | bulletscxx . . $ JJ1Level#bullets. = nullptr; |
| 71 | sceneFilecxx . . $ JJ1Level#sceneFile. = nullptr; |
| 72 | spriteSetcxx . . $ JJ1Level#spriteSet. = nullptr; |
| 73 | skycxx . . $ JJ1Level#sky. = false; |
| 74 | skyOrbcxx . . $ JJ1Level#skyOrb. = 0; |
| 75 | levelNumcxx . . $ JJ1Level#levelNum. = worldNumcxx . . $ JJ1Level#worldNum. = nextLevelNumcxx . . $ JJ1Level#nextLevelNum. = nextWorldNumcxx . . $ JJ1Level#nextWorldNum. = 0; |
| 76 | enemiescxx . . $ JJ1Level#enemies. = 0; |
| 77 | waterLevelcxx . . $ JJ1Level#waterLevel. = waterLevelTargetcxx . . $ JJ1Level#waterLevelTarget. = waterLevelSpeedcxx . . $ JJ1Level#waterLevelSpeed. = 0; |
| 78 | energyBarcxx . . $ JJ1Level#energyBar. = ammoTypecxx . . $ JJ1Level#ammoType. = ammoOffsetcxx . . $ JJ1Level#ammoOffset. = 0; |
| 79 | fontcxx . . $ JJ1Level#font. = nullptr; |
| 80 | musicFilecxx . . $ JJ1Level#musicFile. = nullptr; |
| 81 | } |
| 82 | |
| 83 | |
| 84 | /** |
| 85 | * Create a JJ1 level. |
| 86 | * |
| 87 | * @param owner The current game |
| 88 | * @param fileName Name of the file containing the level data. |
| 89 | * @param checkpoint Whether or not the player(s) will start at a checkpoint |
| 90 | * @param multi Whether or not the level will be multi-player |
| 91 | */ |
| 92 | JJ1Levelcxx . . $ JJ1Level#::JJ1Levelcxx . . $ JJ1Level#JJ1Level(d0e4e14245153d48). (Gamecxx . . $ Game#* owner, char* fileName, bool checkpoint, bool multi) : |
| 93 | Levelcxx . . $ Level# (owner) { |
| 94 | |
| 95 | // Load level data |
| 96 | int ret = loadcxx . . $ JJ1Level#load(ef975b611725403e).(fileName, checkpoint); |
| 97 | if (ret < 0) throw ret; |
| 98 | |
| 99 | multiplayercxx . . $ Level#multiplayer. = multi; |
| 100 | |
| 101 | } |
| 102 | |
| 103 | |
| 104 | /** |
| 105 | * Delete HUD graphical data. |
| 106 | */ |
| 107 | void JJ1Levelcxx . . $ JJ1Level#::deletePanelcxx . . $ JJ1Level#deletePanel(49f6e7a06ebc5aa8). () { |
| 108 | |
| 109 | videocxx . . $ video..destroySurfacecxx . . $ Video#destroySurface(60a0b30a00b4fc6d).(panelcxx . . $ JJ1Level#panel.); |
| 110 | for (int i = 0; i < 6; i++) |
| 111 | videocxx . . $ video..destroySurfacecxx . . $ Video#destroySurface(60a0b30a00b4fc6d).(panelAmmocxx . . $ JJ1Level#panelAmmo.[i]); |
| 112 | for (int i = 0; i < 2; i++) |
| 113 | videocxx . . $ video..destroySurfacecxx . . $ Video#destroySurface(60a0b30a00b4fc6d).(panelBGcxx . . $ JJ1Level#panelBG.[i]); |
| 114 | |
| 115 | } |
| 116 | |
| 117 | |
| 118 | /** |
| 119 | * Delete the JJ1 level. |
| 120 | */ |
| 121 | JJ1Levelcxx . . $ JJ1Level#::~cxx . . $ JJ1Level#`~JJ1Level`(49f6e7a06ebc5aa8).JJ1Levelcxx . . $ JJ1Level# () { |
| 122 | |
| 123 | // Free events |
| 124 | if (eventscxx . . $ JJ1Level#events.) delete eventscxx . . $ JJ1Level#events.; |
| 125 | |
| 126 | // Free bullets |
| 127 | if (bulletscxx . . $ JJ1Level#bullets.) delete bulletscxx . . $ JJ1Level#bullets.; |
| 128 | |
| 129 | for (int i = 0; i < PATHScxx . . $ `src/jj1/level/jj1level.h:53:9`!; i++) { |
| 130 | |
| 131 | delete[] pathcxx . . $ JJ1Level#path.[i].xcxx . . $ $anonymous_type_e8f9ae77bbb68925_2#x.; |
| 132 | delete[] pathcxx . . $ JJ1Level#path.[i].ycxx . . $ $anonymous_type_e8f9ae77bbb68925_2#y.; |
| 133 | |
| 134 | } |
| 135 | |
| 136 | delete[] sceneFilecxx . . $ JJ1Level#sceneFile.; |
| 137 | delete[] musicFilecxx . . $ JJ1Level#musicFile.; |
| 138 | |
| 139 | delete[] spriteSetcxx . . $ JJ1Level#spriteSet.; |
| 140 | |
| 141 | videocxx . . $ video..destroySurfacecxx . . $ Video#destroySurface(60a0b30a00b4fc6d).(tileSetcxx . . $ JJ1Level#tileSet.); |
| 142 | |
| 143 | deletePanelcxx . . $ JJ1Level#deletePanel(49f6e7a06ebc5aa8).(); |
| 144 | |
| 145 | delete fontcxx . . $ JJ1Level#font.; |
| 146 | |
| 147 | resampleSoundscxx . . $ resampleSounds(49f6e7a06ebc5aa8).(); |
| 148 | |
| 149 | videocxx . . $ video..setTitlecxx . . $ Video#setTitle(85c52e162fed56f9).(nullptr); |
| 150 | |
| 151 | } |
| 152 | |
| 153 | |
| 154 | /** |
| 155 | * Determine whether or not the given point is solid when travelling upwards. |
| 156 | * |
| 157 | * @param x X-coordinate |
| 158 | * @param y Y-coordinate |
| 159 | * |
| 160 | * @return Solidity |
| 161 | */ |
| 162 | bool JJ1Levelcxx . . $ JJ1Level#::checkMaskUpcxx . . $ JJ1Level#checkMaskUp(cf9ef193275fa6d8). (fixedcxx . . $ fixed# x, fixedcxx . . $ fixed# y) { |
| 163 | |
| 164 | GridElementcxx . . $ GridElement# *ge; |
| 165 | |
| 166 | // Anything off the edge of the map is solid |
| 167 | if ((x < 0) || (y < 0) || (x >= TTOFcxx . . $ `src/level/level.h:38:9`!(LWcxx . . $ `src/jj1/level/jj1level.h:43:9`!)) || (y >= TTOFcxx . . $ `src/level/level.h:38:9`!(LHcxx . . $ `src/jj1/level/jj1level.h:44:9`!))) |
| 168 | return true; |
| 169 | |
| 170 | ge = gridcxx . . $ JJ1Level#grid.[FTOTcxx . . $ `src/level/level.h:37:9`!(y)] + FTOTcxx . . $ `src/level/level.h:37:9`!(x); |
| 171 | |
| 172 | // JJ1Event 122 is one-way |
| 173 | if (ge->eventcxx . . $ $anonymous_type_e8f9ae77bbb68925_0#event. == 122) return false; |
| 174 | |
| 175 | // Check the mask in the tile in question |
| 176 | return maskcxx . . $ JJ1Level#mask.[ge->tilecxx . . $ $anonymous_type_e8f9ae77bbb68925_0#tile.][((y >> 9) & 56) + ((x >> 12) & 7)]; |
| 177 | |
| 178 | } |
| 179 | |
| 180 | |
| 181 | /** |
| 182 | * Determine whether or not the given point is solid when travelling downwards. |
| 183 | * |
| 184 | * @param x X-coordinate |
| 185 | * @param y Y-coordinate |
| 186 | * |
| 187 | * @return Solidity |
| 188 | */ |
| 189 | bool JJ1Levelcxx . . $ JJ1Level#::checkMaskDowncxx . . $ JJ1Level#checkMaskDown(cf9ef193275fa6d8). (fixedcxx . . $ fixed# x, fixedcxx . . $ fixed# y) { |
| 190 | |
| 191 | // Anything off the edge of the map is solid |
| 192 | if ((x < 0) || (y < 0) || (x >= TTOFcxx . . $ `src/level/level.h:38:9`!(LWcxx . . $ `src/jj1/level/jj1level.h:43:9`!)) || (y >= TTOFcxx . . $ `src/level/level.h:38:9`!(LHcxx . . $ `src/jj1/level/jj1level.h:44:9`!))) |
| 193 | return true; |
| 194 | |
| 195 | // Check the mask in the tile in question |
| 196 | return maskcxx . . $ JJ1Level#mask.[gridcxx . . $ JJ1Level#grid.[FTOTcxx . . $ `src/level/level.h:37:9`!(y)][FTOTcxx . . $ `src/level/level.h:37:9`!(x)].tilecxx . . $ $anonymous_type_e8f9ae77bbb68925_0#tile.][((y >> 9) & 56) + ((x >> 12) & 7)]; |
| 197 | |
| 198 | } |
| 199 | |
| 200 | |
| 201 | /** |
| 202 | * Determine whether or not the given point should cause damage to the player. |
| 203 | * |
| 204 | * @param x X-coordinate |
| 205 | * @param y Y-coordinate |
| 206 | * |
| 207 | * @return Painful solidity |
| 208 | */ |
| 209 | bool JJ1Levelcxx . . $ JJ1Level#::checkSpikescxx . . $ JJ1Level#checkSpikes(cf9ef193275fa6d8). (fixedcxx . . $ fixed# x, fixedcxx . . $ fixed# y) { |
| 210 | |
| 211 | GridElementcxx . . $ GridElement# *ge; |
| 212 | |
| 213 | // Anything off the edge of the map is not spikes |
| 214 | // Ignore the bottom, as it is deadly anyway |
| 215 | if ((x < 0) || (y < 0) || (x > TTOFcxx . . $ `src/level/level.h:38:9`!(LWcxx . . $ `src/jj1/level/jj1level.h:43:9`!))) return false; |
| 216 | |
| 217 | ge = gridcxx . . $ JJ1Level#grid.[FTOTcxx . . $ `src/level/level.h:37:9`!(y)] + FTOTcxx . . $ `src/level/level.h:37:9`!(x); |
| 218 | |
| 219 | // JJ1Event 126 is spikes |
| 220 | if (ge->eventcxx . . $ $anonymous_type_e8f9ae77bbb68925_0#event. != 126) return false; |
| 221 | |
| 222 | // Check the mask in the tile in question |
| 223 | return maskcxx . . $ JJ1Level#mask.[ge->tilecxx . . $ $anonymous_type_e8f9ae77bbb68925_0#tile.][((y >> 9) & 56) + ((x >> 12) & 7)]; |
| 224 | |
| 225 | } |
| 226 | |
| 227 | |
| 228 | /** |
| 229 | * Determine the level's world number. |
| 230 | * |
| 231 | * @return World number |
| 232 | */ |
| 233 | int JJ1Levelcxx . . $ JJ1Level#::getWorldcxx . . $ JJ1Level#getWorld(b126dc7c1de90089).() { |
| 234 | |
| 235 | return worldNumcxx . . $ JJ1Level#worldNum.; |
| 236 | |
| 237 | } |
| 238 | |
| 239 | |
| 240 | /** |
| 241 | * Set which level will come next. |
| 242 | * |
| 243 | * @param nextLevel Next level's number |
| 244 | * @param nextWorld Next level's world number |
| 245 | */ |
| 246 | void JJ1Levelcxx . . $ JJ1Level#::setNextcxx . . $ JJ1Level#setNext(3e454b8ccf442868). (int nextLevel, int nextWorld) { |
| 247 | |
| 248 | nextLevelNumcxx . . $ JJ1Level#nextLevelNum. = nextLevel; |
| 249 | nextWorldNumcxx . . $ JJ1Level#nextWorldNum. = nextWorld; |
| 250 | |
| 251 | if(nextLevelNumcxx . . $ JJ1Level#nextLevelNum. == 99 || nextWorldNumcxx . . $ JJ1Level#nextWorldNum. == 99) { |
| 252 | LOG_MAXcxx . . $ `src/io/log.h:73:9`!("No next level available, episode/game will end"); |
| 253 | } else { |
| 254 | LOG_MAXcxx . . $ `src/io/log.h:73:9`!("Next level is LEVEL%d.%03d", nextLevelNum, nextWorldNum); |
| 255 | } |
| 256 | |
| 257 | if (multiplayercxx . . $ Level#multiplayer.) { |
| 258 | |
| 259 | unsigned char buffer[MTL_L_PROPcxx . . $ `src/game/game.h:71:9`!]; |
| 260 | buffer[0] = MTL_L_PROPcxx . . $ `src/game/game.h:71:9`!; |
| 261 | buffer[1] = MT_L_PROPcxx . . $ `src/game/game.h:55:9`!; |
| 262 | buffer[2] = 0; // set next level |
| 263 | buffer[3] = nextLevel; |
| 264 | buffer[4] = nextWorld; |
| 265 | |
| 266 | gamecxx . . $ Level#game.->sendcxx . . $ Game#send(f25546b61a629de7).(buffer); |
| 267 | |
| 268 | } |
| 269 | |
| 270 | } |
| 271 | |
| 272 | |
| 273 | /** |
| 274 | * Set the tile at the given location. |
| 275 | * |
| 276 | * @param gridX X-coordinate of the tile |
| 277 | * @param gridY Y-coordinate of the tile |
| 278 | * @param tile The new tile |
| 279 | */ |
| 280 | void JJ1Levelcxx . . $ JJ1Level#::setTilecxx . . $ JJ1Level#setTile(684ed43ade99b32e). (unsigned char gridX, unsigned char gridY, unsigned char tile) { |
| 281 | |
| 282 | gridcxx . . $ JJ1Level#grid.[gridY][gridX].tilecxx . . $ $anonymous_type_e8f9ae77bbb68925_0#tile. = tile; |
| 283 | |
| 284 | if (multiplayercxx . . $ Level#multiplayer.) { |
| 285 | |
| 286 | unsigned char buffer[MTL_L_GRIDcxx . . $ `src/game/game.h:72:9`!]; |
| 287 | buffer[0] = MTL_L_GRIDcxx . . $ `src/game/game.h:72:9`!; |
| 288 | buffer[1] = MT_L_GRIDcxx . . $ `src/game/game.h:56:9`!; |
| 289 | buffer[2] = gridX; |
| 290 | buffer[3] = gridY; |
| 291 | buffer[4] = 0; // tile variable |
| 292 | buffer[5] = tile; |
| 293 | |
| 294 | gamecxx . . $ Level#game.->sendcxx . . $ Game#send(f25546b61a629de7).(buffer); |
| 295 | |
| 296 | } |
| 297 | |
| 298 | } |
| 299 | |
| 300 | |
| 301 | difficultyTypecxx . . $ difficultyType# JJ1Levelcxx . . $ JJ1Level#::getDifficultycxx . . $ JJ1Level#getDifficulty(601dbc13202031c0). () { |
| 302 | return gamecxx . . $ Level#game.->getDifficultycxx . . $ Game#getDifficulty(601dbc13202031c0).(); |
| 303 | } |
| 304 | |
| 305 | |
| 306 | /** |
| 307 | * Get the active events. |
| 308 | * |
| 309 | * @return The first active event |
| 310 | */ |
| 311 | JJ1Eventcxx . . $ JJ1Event#* JJ1Levelcxx . . $ JJ1Level#::getEventscxx . . $ JJ1Level#getEvents(31caec775bb17100). () { |
| 312 | |
| 313 | return eventscxx . . $ JJ1Level#events.; |
| 314 | |
| 315 | } |
| 316 | |
| 317 | |
| 318 | /** |
| 319 | * Get the event data for the event from the given tile. |
| 320 | * |
| 321 | * @param gridX X-coordinate of the tile |
| 322 | * @param gridY Y-coordinate of the tile |
| 323 | * |
| 324 | * @return JJ1Event data |
| 325 | */ |
| 326 | JJ1EventTypecxx . . $ JJ1EventType#* JJ1Levelcxx . . $ JJ1Level#::getEventcxx . . $ JJ1Level#getEvent(4d9fc4215ff36191). (unsigned char gridX, unsigned char gridY) { |
| 327 | |
| 328 | int event = gridcxx . . $ JJ1Level#grid.[gridY][gridX].eventcxx . . $ $anonymous_type_e8f9ae77bbb68925_0#event.; |
| 329 | |
| 330 | if (event) return eventSetcxx . . $ JJ1Level#eventSet. + event; |
| 331 | |
| 332 | return nullptr; |
| 333 | |
| 334 | } |
| 335 | |
| 336 | |
| 337 | /** |
| 338 | * Get the hits incurred by the event from the given tile. |
| 339 | * |
| 340 | * @param gridX X-coordinate of the tile |
| 341 | * @param gridY Y-coordinate of the tile |
| 342 | * |
| 343 | * @return Number of hits |
| 344 | */ |
| 345 | unsigned char JJ1Levelcxx . . $ JJ1Level#::getEventHitscxx . . $ JJ1Level#getEventHits(777233acce9323bd). (unsigned char gridX, unsigned char gridY) { |
| 346 | |
| 347 | return gridcxx . . $ JJ1Level#grid.[gridY][gridX].hitscxx . . $ $anonymous_type_e8f9ae77bbb68925_0#hits.; |
| 348 | |
| 349 | } |
| 350 | |
| 351 | |
| 352 | /** |
| 353 | * Get the set time for the event from the given tile. |
| 354 | * |
| 355 | * @param gridX X-coordinate of the tile |
| 356 | * @param gridY Y-coordinate of the tile |
| 357 | * |
| 358 | * @return Time |
| 359 | */ |
| 360 | unsigned int JJ1Levelcxx . . $ JJ1Level#::getEventTimecxx . . $ JJ1Level#getEventTime(ce7b340bf7a3914f). (unsigned char gridX, unsigned char gridY) { |
| 361 | |
| 362 | return gridcxx . . $ JJ1Level#grid.[gridY][gridX].timecxx . . $ $anonymous_type_e8f9ae77bbb68925_0#time.; |
| 363 | |
| 364 | } |
| 365 | |
| 366 | |
| 367 | /** |
| 368 | * Remove the event from the given tile. |
| 369 | * |
| 370 | * @param gridX X-coordinate of the tile |
| 371 | * @param gridY Y-coordinate of the tile |
| 372 | */ |
| 373 | void JJ1Levelcxx . . $ JJ1Level#::clearEventcxx . . $ JJ1Level#clearEvent(8fbe6856f5410d23). (unsigned char gridX, unsigned char gridY) { |
| 374 | |
| 375 | // Ignore if the event has been un-destroyed |
| 376 | if (!gridcxx . . $ JJ1Level#grid.[gridY][gridX].hitscxx . . $ $anonymous_type_e8f9ae77bbb68925_0#hits. && |
| 377 | eventSetcxx . . $ JJ1Level#eventSet.[gridcxx . . $ JJ1Level#grid.[gridY][gridX].eventcxx . . $ $anonymous_type_e8f9ae77bbb68925_0#event.].strengthcxx . . $ $anonymous_type_e8f9ae77bbb68925_1#strength.) return; |
| 378 | |
| 379 | gridcxx . . $ JJ1Level#grid.[gridY][gridX].eventcxx . . $ $anonymous_type_e8f9ae77bbb68925_0#event. = 0; |
| 380 | |
| 381 | if (multiplayercxx . . $ Level#multiplayer.) { |
| 382 | |
| 383 | unsigned char buffer[MTL_L_GRIDcxx . . $ `src/game/game.h:72:9`!]; |
| 384 | buffer[0] = MTL_L_GRIDcxx . . $ `src/game/game.h:72:9`!; |
| 385 | buffer[1] = MT_L_GRIDcxx . . $ `src/game/game.h:56:9`!; |
| 386 | buffer[2] = gridX; |
| 387 | buffer[3] = gridY; |
| 388 | buffer[4] = 2; // event variable |
| 389 | buffer[5] = 0; |
| 390 | |
| 391 | gamecxx . . $ Level#game.->sendcxx . . $ Game#send(f25546b61a629de7).(buffer); |
| 392 | |
| 393 | } |
| 394 | |
| 395 | } |
| 396 | |
| 397 | |
| 398 | /** |
| 399 | * Register hit(s) on the event for the given tile. |
| 400 | * |
| 401 | * @param gridX X-coordinate of the tile |
| 402 | * @param gridY Y-coordinate of the tile |
| 403 | * @param hits The number of hits to attempt to inflict on the event |
| 404 | * @param source The player that inflicted the hit(s) |
| 405 | * @param time Time |
| 406 | * |
| 407 | * @return The remaining number of hits until the event is destroyed |
| 408 | */ |
| 409 | int JJ1Levelcxx . . $ JJ1Level#::hitEventcxx . . $ JJ1Level#hitEvent(21563437c91e9cad). (unsigned char gridX, unsigned char gridY, int hits, JJ1LevelPlayercxx . . $ JJ1LevelPlayer#* source, unsigned int time) { |
| 410 | |
| 411 | GridElementcxx . . $ GridElement# *ge = gridcxx . . $ JJ1Level#grid.[gridY] + gridX; |
| 412 | int hitsToKill = eventSetcxx . . $ JJ1Level#eventSet.[ge->eventcxx . . $ $anonymous_type_e8f9ae77bbb68925_0#event.].strengthcxx . . $ $anonymous_type_e8f9ae77bbb68925_1#strength.; |
| 413 | |
| 414 | // If the event cannot be hit, return negative |
| 415 | if (!hitsToKill || (ge->hitscxx . . $ $anonymous_type_e8f9ae77bbb68925_0#hits. == 255)) return -1; |
| 416 | |
| 417 | // In turbo difficulty, enemy events generally take one more hit |
| 418 | if (getDifficultycxx . . $ JJ1Level#getDifficulty(601dbc13202031c0).() == difficultyTypecxx . . $ difficultyType#::Turbocxx . . $ difficultyType#Turbo. && eventSetcxx . . $ JJ1Level#eventSet.[ge->eventcxx . . $ $anonymous_type_e8f9ae77bbb68925_0#event.].modifiercxx . . $ $anonymous_type_e8f9ae77bbb68925_1#modifier. == 0) |
| 419 | hitsToKill++; |
| 420 | |
| 421 | // If the event has already been destroyed, do nothing |
| 422 | if (ge->hitscxx . . $ $anonymous_type_e8f9ae77bbb68925_0#hits. >= hitsToKill) return 0; |
| 423 | |
| 424 | // Check if the event has been killed |
| 425 | if (ge->hitscxx . . $ $anonymous_type_e8f9ae77bbb68925_0#hits. + hits >= hitsToKill) { |
| 426 | |
| 427 | // Notify the player that shot the bullet |
| 428 | // If this returns false, ignore the hit |
| 429 | if (!source->takeEventcxx . . $ JJ1LevelPlayer#takeEvent(b0f9bb2b2e8e7dc7).(eventSetcxx . . $ JJ1Level#eventSet. + ge->eventcxx . . $ $anonymous_type_e8f9ae77bbb68925_0#event., gridX, gridY, tickscxx . . $ Level#ticks.)) { |
| 430 | |
| 431 | return hitsToKill - ge->hitscxx . . $ $anonymous_type_e8f9ae77bbb68925_0#hits.; |
| 432 | |
| 433 | } |
| 434 | |
| 435 | ge->hitscxx . . $ $anonymous_type_e8f9ae77bbb68925_0#hits. = (hits == 255)? 255: hitsToKill; |
| 436 | ge->timecxx . . $ $anonymous_type_e8f9ae77bbb68925_0#time. = time; |
| 437 | |
| 438 | } else { |
| 439 | |
| 440 | ge->hitscxx . . $ $anonymous_type_e8f9ae77bbb68925_0#hits. += hits; |
| 441 | |
| 442 | } |
| 443 | |
| 444 | if (multiplayercxx . . $ Level#multiplayer.) { |
| 445 | |
| 446 | unsigned char buffer[MTL_L_GRIDcxx . . $ `src/game/game.h:72:9`!]; |
| 447 | buffer[0] = MTL_L_GRIDcxx . . $ `src/game/game.h:72:9`!; |
| 448 | buffer[1] = MT_L_GRIDcxx . . $ `src/game/game.h:56:9`!; |
| 449 | buffer[2] = gridX; |
| 450 | buffer[3] = gridY; |
| 451 | buffer[4] = 3; // hits variable |
| 452 | buffer[5] = ge->hitscxx . . $ $anonymous_type_e8f9ae77bbb68925_0#hits.; |
| 453 | |
| 454 | gamecxx . . $ Level#game.->sendcxx . . $ Game#send(f25546b61a629de7).(buffer); |
| 455 | |
| 456 | } |
| 457 | |
| 458 | return hitsToKill - ge->hitscxx . . $ $anonymous_type_e8f9ae77bbb68925_0#hits.; |
| 459 | |
| 460 | } |
| 461 | |
| 462 | |
| 463 | /** |
| 464 | * Set the time of the event from the given tile. |
| 465 | * |
| 466 | * @param gridX X-coordinate of the tile |
| 467 | * @param gridY Y-coordinate of the tile |
| 468 | * @param time Time |
| 469 | */ |
| 470 | void JJ1Levelcxx . . $ JJ1Level#::setEventTimecxx . . $ JJ1Level#setEventTime(4a4a5f1b8fcd3f2e). (unsigned char gridX, unsigned char gridY, unsigned int time) { |
| 471 | |
| 472 | gridcxx . . $ JJ1Level#grid.[gridY][gridX].timecxx . . $ $anonymous_type_e8f9ae77bbb68925_0#time. = time; |
| 473 | |
| 474 | } |
| 475 | |
| 476 | |
| 477 | /** |
| 478 | * Get a sprite. |
| 479 | * |
| 480 | * @param sprite Sprite number |
| 481 | * |
| 482 | * @return Sprite |
| 483 | */ |
| 484 | Spritecxx . . $ Sprite#* JJ1Levelcxx . . $ JJ1Level#::getSpritecxx . . $ JJ1Level#getSprite(a0024ee756d0a8). (unsigned char sprite) { |
| 485 | |
| 486 | return spriteSetcxx . . $ JJ1Level#spriteSet. + sprite; |
| 487 | |
| 488 | } |
| 489 | |
| 490 | |
| 491 | /** |
| 492 | * Get an animation. |
| 493 | * |
| 494 | * @param anim Animation number |
| 495 | * |
| 496 | * @return Animation |
| 497 | */ |
| 498 | Animcxx . . $ Anim#* JJ1Levelcxx . . $ JJ1Level#::getAnimcxx . . $ JJ1Level#getAnim(e50c847d642a1093). (unsigned char anim) { |
| 499 | |
| 500 | return animSetcxx . . $ JJ1Level#animSet. + anim; |
| 501 | |
| 502 | } |
| 503 | |
| 504 | |
| 505 | /** |
| 506 | * Get a "miscellaneous" animation. |
| 507 | * |
| 508 | * @param anim Animation number |
| 509 | * |
| 510 | * @return Animation |
| 511 | */ |
| 512 | Animcxx . . $ Anim#* JJ1Levelcxx . . $ JJ1Level#::getMiscAnimcxx . . $ JJ1Level#getMiscAnim(e50c847d642a1093). (unsigned char anim) { |
| 513 | |
| 514 | return animSetcxx . . $ JJ1Level#animSet. + miscAnimscxx . . $ JJ1Level#miscAnims.[anim]; |
| 515 | |
| 516 | } |
| 517 | |
| 518 | |
| 519 | /** |
| 520 | * Get a player animation. |
| 521 | * |
| 522 | * @param anim Animation number |
| 523 | * |
| 524 | * @return Animation |
| 525 | */ |
| 526 | Animcxx . . $ Anim#* JJ1Levelcxx . . $ JJ1Level#::getPlayerAnimcxx . . $ JJ1Level#getPlayerAnim(e50c847d642a1093). (unsigned char anim) { |
| 527 | |
| 528 | return animSetcxx . . $ JJ1Level#animSet. + playerAnimscxx . . $ JJ1Level#playerAnims.[anim]; |
| 529 | |
| 530 | } |
| 531 | |
| 532 | /** |
| 533 | * Get a level animation. |
| 534 | * |
| 535 | * @param anim Animation number |
| 536 | * |
| 537 | * @return Animation |
| 538 | */ |
| 539 | Animcxx . . $ Anim#* JJ1Levelcxx . . $ JJ1Level#::getLevelAnimcxx . . $ JJ1Level#getLevelAnim(e50c847d642a1093). (unsigned char anim) { |
| 540 | |
| 541 | return animSetcxx . . $ JJ1Level#animSet. + levelAnimscxx . . $ JJ1Level#levelAnims.[anim]; |
| 542 | |
| 543 | } |
| 544 | |
| 545 | /** |
| 546 | * Get a level sound. |
| 547 | * |
| 548 | * @param sound Sound number |
| 549 | * |
| 550 | * @return Sound |
| 551 | */ |
| 552 | SEcxx . . $ SE/::Typecxx . . $ SE/Type# JJ1Levelcxx . . $ JJ1Level#::getLevelSoundcxx . . $ JJ1Level#getLevelSound(855d83035cfb1d19). (unsigned char sound) { |
| 553 | |
| 554 | return static_cast<SEcxx . . $ SE/::Typecxx . . $ SE/Type#>(levelSoundscxx . . $ JJ1Level#levelSounds.[sound]); |
| 555 | |
| 556 | } |
| 557 | |
| 558 | |
| 559 | /** |
| 560 | * Set the water level. |
| 561 | * |
| 562 | * @param gridY New water level y-coordinate |
| 563 | */ |
| 564 | void JJ1Levelcxx . . $ JJ1Level#::setWaterLevelcxx . . $ JJ1Level#setWaterLevel(ac50b47256ae7414). (unsigned char gridY) { |
| 565 | |
| 566 | waterLevelTargetcxx . . $ JJ1Level#waterLevelTarget. = TTOFcxx . . $ `src/level/level.h:38:9`!(gridY) + F2cxx . . $ `src/types.h:32:9`!; |
| 567 | |
| 568 | if (multiplayercxx . . $ Level#multiplayer.) { |
| 569 | |
| 570 | unsigned char buffer[MTL_L_PROPcxx . . $ `src/game/game.h:71:9`!]; |
| 571 | buffer[0] = MTL_L_PROPcxx . . $ `src/game/game.h:71:9`!; |
| 572 | buffer[1] = MT_L_PROPcxx . . $ `src/game/game.h:55:9`!; |
| 573 | buffer[2] = 1; // set water level |
| 574 | buffer[3] = gridY; |
| 575 | buffer[4] = 0; // Doesn't really matter |
| 576 | |
| 577 | gamecxx . . $ Level#game.->sendcxx . . $ Game#send(f25546b61a629de7).(buffer); |
| 578 | |
| 579 | } |
| 580 | |
| 581 | } |
| 582 | |
| 583 | |
| 584 | /** |
| 585 | * Determine the water level. |
| 586 | * |
| 587 | * @return The y-coordinate of the water level |
| 588 | */ |
| 589 | fixedcxx . . $ fixed# JJ1Levelcxx . . $ JJ1Level#::getWaterLevelcxx . . $ JJ1Level#getWaterLevel(b126dc7c1de90089). () { |
| 590 | |
| 591 | return waterLevelcxx . . $ JJ1Level#waterLevel.; |
| 592 | |
| 593 | } |
| 594 | |
| 595 | |
| 596 | /** |
| 597 | * Create new bullet(s) (or event(s), if applicable) |
| 598 | * |
| 599 | * @param sourcePlayer The player that fired the bullet (if any) |
| 600 | * @param gridX The grid X-coordinate of the origin of the event that fired the bullet (if any) |
| 601 | * @param gridY The grid Y-coordinate of the origin of the event that fired the bullet (if any) |
| 602 | * @param startX The initial X-coordinate of the bullet |
| 603 | * @param startY The initial Y-coordinate of the bullet |
| 604 | * @param bullet Type |
| 605 | * @param facing The direction of the bullet |
| 606 | * @param time Time |
| 607 | */ |
| 608 | void JJ1Levelcxx . . $ JJ1Level#::createBulletcxx . . $ JJ1Level#createBullet(a881a95dff2117e9). (JJ1LevelPlayercxx . . $ JJ1LevelPlayer#* sourcePlayer, unsigned char gridX, unsigned char gridY, fixedcxx . . $ fixed# startX, fixedcxx . . $ fixed# startY, unsigned char bullet, bool facing, unsigned int time) { |
| 609 | |
| 610 | signed char* set; |
| 611 | int direction; |
| 612 | |
| 613 | set = bulletSetcxx . . $ JJ1Level#bulletSet.[bullet]; |
| 614 | |
| 615 | direction = facing? 1: 0; |
| 616 | |
| 617 | if (set[B_GRAVITYcxx . . $ `src/jj1/level/jj1bullet.h:39:9`! | direction] == 4) { |
| 618 | |
| 619 | eventscxx . . $ JJ1Level#events. = new JJ1StandardEventcxx . . $ JJ1StandardEvent#(eventSetcxx . . $ JJ1Level#eventSet. + set[B_SPRITEcxx . . $ `src/jj1/level/jj1bullet.h:36:9`! | direction], gridX, gridY, startX, startY + F32cxx . . $ `src/types.h:40:9`!); |
| 620 | |
| 621 | } else if (set[B_SPRITEcxx . . $ `src/jj1/level/jj1bullet.h:36:9`! | direction] != 0) { |
| 622 | |
| 623 | // Create new bullet |
| 624 | levelcxx . . $ level.->bulletscxx . . $ JJ1Level#bullets. = new JJ1Bulletcxx . . $ JJ1Bullet#(levelcxx . . $ level.->bulletscxx . . $ JJ1Level#bullets., |
| 625 | sourcePlayer, |
| 626 | startX, |
| 627 | startY, |
| 628 | set, |
| 629 | direction, |
| 630 | time); |
| 631 | |
| 632 | if (set[B_XSPEEDcxx . . $ `src/jj1/level/jj1bullet.h:37:9`! | direction | 2] != 0) { |
| 633 | |
| 634 | // Create the other bullet |
| 635 | levelcxx . . $ level.->bulletscxx . . $ JJ1Level#bullets. = new JJ1Bulletcxx . . $ JJ1Bullet#(levelcxx . . $ level.->bulletscxx . . $ JJ1Level#bullets., |
| 636 | sourcePlayer, |
| 637 | startX, |
| 638 | startY, |
| 639 | set, |
| 640 | direction | 2, |
| 641 | time); |
| 642 | |
| 643 | } |
| 644 | |
| 645 | // FIXME: rewrite "set" |
| 646 | auto se = static_cast<SEcxx . . $ SE/::Typecxx . . $ SE/Type#>(set[B_STARTSOUNDcxx . . $ `src/jj1/level/jj1bullet.h:44:9`!]); |
| 647 | playSoundcxx . . $ playSound(80b838f98135e5b).(se); |
| 648 | |
| 649 | } |
| 650 | |
| 651 | } |
| 652 | |
| 653 | |
| 654 | /** |
| 655 | * Start a flash palette effect. |
| 656 | * |
| 657 | * @param red Red component of flash colour |
| 658 | * @param green Green component of flash colour |
| 659 | * @param blue Blue component of flash colour |
| 660 | * @param duration Duration of the flash effect |
| 661 | */ |
| 662 | void JJ1Levelcxx . . $ JJ1Level#::flashcxx . . $ JJ1Level#flash(1b04462a7c7a7926). (unsigned char red, unsigned char green, unsigned char blue, int duration) { |
| 663 | |
| 664 | paletteEffectscxx . . $ Level#paletteEffects. = new FlashPaletteEffectcxx . . $ FlashPaletteEffect#(red, green, blue, duration, paletteEffectscxx . . $ Level#paletteEffects.); |
| 665 | |
| 666 | } |
| 667 | |
| 668 | |
| 669 | /** |
| 670 | * Play the bonus level. |
| 671 | * |
| 672 | * @return Error code |
| 673 | */ |
| 674 | int JJ1Levelcxx . . $ JJ1Level#::playBonuscxx . . $ JJ1Level#playBonus(b126dc7c1de90089). () { |
| 675 | |
| 676 | char *bonusFile; |
| 677 | int ret; |
| 678 | |
| 679 | if (!localPlayercxx . . $ localPlayer.->getJJ1LevelPlayercxx . . $ Player#getJJ1LevelPlayer(cf23ec4c0d6db922).()->hasGemcxx . . $ JJ1LevelPlayer#hasGem(c9857a73d68e59ba).()) return E_NONEcxx . . $ `src/OpenJazz.h:69:9`!; |
| 680 | |
| 681 | delete paletteEffectscxx . . $ Level#paletteEffects.; |
| 682 | paletteEffectscxx . . $ Level#paletteEffects. = nullptr; |
| 683 | |
| 684 | bonusFile = createFileNamecxx . . $ createFileName(2050848944e00d54).("BONUSMAP", worldToEpisodecxx . . $ worldToEpisode(7864480464b09eea).(worldNumcxx . . $ JJ1Level#worldNum.)); |
| 685 | |
| 686 | // If the gem has been collected, play the bonus level |
| 687 | ret = gamecxx . . $ Level#game.->playLevelcxx . . $ Game#playLevel(1ef8e6ec083aabb9).(bonusFile); |
| 688 | |
| 689 | delete[] bonusFile; |
| 690 | |
| 691 | return ret; |
| 692 | |
| 693 | } |
| 694 | |
| 695 | |
| 696 | /** |
| 697 | * Interpret data received from client/server |
| 698 | * |
| 699 | * @param buffer Received data |
| 700 | */ |
| 701 | void JJ1Levelcxx . . $ JJ1Level#::receivecxx . . $ JJ1Level#receive(f25546b61a629de7). (unsigned char* buffer) { |
| 702 | |
| 703 | switch (buffer[1]) { |
| 704 | |
| 705 | case MT_L_PROPcxx . . $ `src/game/game.h:55:9`!: |
| 706 | |
| 707 | if (buffer[2] == 0) { |
| 708 | |
| 709 | nextLevelNumcxx . . $ JJ1Level#nextLevelNum. = buffer[3]; |
| 710 | nextWorldNumcxx . . $ JJ1Level#nextWorldNum. = buffer[4]; |
| 711 | |
| 712 | } else if (buffer[2] == 1) { |
| 713 | |
| 714 | waterLevelTargetcxx . . $ JJ1Level#waterLevelTarget. = TTOFcxx . . $ `src/level/level.h:38:9`!(buffer[3]); |
| 715 | |
| 716 | } else if (buffer[2] == 2) { |
| 717 | |
| 718 | if (stagecxx . . $ Level#stage. == LS_NORMALcxx . . $ LS_NORMAL.) |
| 719 | endTimecxx . . $ Level#endTime. += buffer[3] * 1000; |
| 720 | |
| 721 | } |
| 722 | |
| 723 | break; |
| 724 | |
| 725 | case MT_L_GRIDcxx . . $ `src/game/game.h:56:9`!: |
| 726 | |
| 727 | if (buffer[4] == 0) gridcxx . . $ JJ1Level#grid.[buffer[3]][buffer[2]].tilecxx . . $ $anonymous_type_e8f9ae77bbb68925_0#tile. = buffer[5]; |
| 728 | else if (buffer[4] == 2) |
| 729 | gridcxx . . $ JJ1Level#grid.[buffer[3]][buffer[2]].eventcxx . . $ $anonymous_type_e8f9ae77bbb68925_0#event. = buffer[5]; |
| 730 | else if (buffer[4] == 3) |
| 731 | gridcxx . . $ JJ1Level#grid.[buffer[3]][buffer[2]].hitscxx . . $ $anonymous_type_e8f9ae77bbb68925_0#hits. = buffer[5]; |
| 732 | |
| 733 | break; |
| 734 | |
| 735 | case MT_L_STAGEcxx . . $ `src/game/game.h:57:9`!: |
| 736 | |
| 737 | stagecxx . . $ Level#stage. = LevelStagecxx . . $ LevelStage#(buffer[2]); |
| 738 | |
| 739 | break; |
| 740 | |
| 741 | } |
| 742 | |
| 743 | } |
| 744 | |
| 745 | |
| 746 | /** |
| 747 | * Play the level. |
| 748 | * |
| 749 | * @return Error code |
| 750 | */ |
| 751 | int JJ1Levelcxx . . $ JJ1Level#::playcxx . . $ JJ1Level#play(b126dc7c1de90089). () { |
| 752 | JJ1LevelPlayercxx . . $ JJ1LevelPlayer#* levelPlayer = localPlayercxx . . $ localPlayer.->getJJ1LevelPlayercxx . . $ Player#getJJ1LevelPlayer(cf23ec4c0d6db922).(); |
| 753 | tickOffsetcxx . . $ Level#tickOffset. = globalTickscxx . . $ globalTicks.; |
| 754 | tickscxx . . $ Level#ticks. = T_STEPcxx . . $ `src/level/level.h:50:9`!; |
| 755 | stepscxx . . $ Level#steps. = 0; |
| 756 | bool pmessage = false, pmenu = false; |
| 757 | int option = 0; |
| 758 | |
| 759 | unsigned int returnTime = 0; |
| 760 | int timeBonus = -1; |
| 761 | int perfect = 0, enemyPercent = 0, itemPercent = 0; |
| 762 | |
| 763 | videocxx . . $ video..setPalettecxx . . $ Video#setPalette(d5421d17e1a4b2b2).(palettecxx . . $ Level#palette.); |
| 764 | |
| 765 | playMusiccxx . . $ playMusic(90ef5b561fbcb8de).(musicFilecxx . . $ JJ1Level#musicFile.); |
| 766 | |
| 767 | while (true) { |
| 768 | |
| 769 | int ret = loopcxx . . $ Level#loop(98496cf6cd60cdee).(pmenu, option, pmessage); |
| 770 | if (ret < 0) return ret; |
| 771 | |
| 772 | // Check if level has been won |
| 773 | if (gamecxx . . $ Level#game. && returnTime && (tickscxx . . $ Level#ticks. > returnTime)) { |
| 774 | |
| 775 | // Play "Level end" cutscene |
| 776 | // if available and secret level 2 was not found (FIXME: check JJ1, if true) |
| 777 | if (strlen(sceneFilecxx . . $ JJ1Level#sceneFile.) && nextLevelNumcxx . . $ JJ1Level#nextLevelNum. != 2) { |
| 778 | if (playScenecxx . . $ Level#playScene(5c4306d8553b3696).(sceneFilecxx . . $ JJ1Level#sceneFile.) == E_QUITcxx . . $ `src/OpenJazz.h:67:9`!) return E_QUITcxx . . $ `src/OpenJazz.h:67:9`!; |
| 779 | } |
| 780 | |
| 781 | if (!multiplayercxx . . $ Level#multiplayer.) { |
| 782 | // If the gem has been collected, play the bonus level |
| 783 | ret = playBonuscxx . . $ JJ1Level#playBonus(b126dc7c1de90089).(); |
| 784 | |
| 785 | if (ret < 0) return ret; |
| 786 | } |
| 787 | |
| 788 | // No next level, end game |
| 789 | if (nextLevelNumcxx . . $ JJ1Level#nextLevelNum. == 99) { |
| 790 | ret = gamecxx . . $ Level#game.->setLevelcxx . . $ Game#setLevel(1ef8e6ec083aabb9).(nullptr); |
| 791 | } else { |
| 792 | // Advance to next level |
| 793 | char *string = createFileNamecxx . . $ createFileName(dc9afb5388f048cb).("LEVEL", nextLevelNumcxx . . $ JJ1Level#nextLevelNum., nextWorldNumcxx . . $ JJ1Level#nextWorldNum.); |
| 794 | ret = gamecxx . . $ Level#game.->setLevelcxx . . $ Game#setLevel(1ef8e6ec083aabb9).(string); |
| 795 | delete[] string; |
| 796 | } |
| 797 | |
| 798 | if (ret < 0) return ret; |
| 799 | |
| 800 | return WONcxx . . $ `src/level/level.h:46:9`!; |
| 801 | } |
| 802 | |
| 803 | |
| 804 | // Process frame-by-frame activity |
| 805 | |
| 806 | while (getTimeChangecxx . . $ Level#getTimeChange(b126dc7c1de90089).() >= T_STEPcxx . . $ `src/level/level.h:50:9`!) { |
| 807 | |
| 808 | bool playerWasAlive = (localPlayercxx . . $ localPlayer.->getJJ1LevelPlayercxx . . $ Player#getJJ1LevelPlayer(cf23ec4c0d6db922).()->getEnergycxx . . $ JJ1LevelPlayer#getEnergy(b126dc7c1de90089).() != 0); |
| 809 | |
| 810 | // Apply controls to local player |
| 811 | for (int i = 0; i < PCONTROLScxx . . $ `src/player/player.h:45:9`!; i++) |
| 812 | localPlayercxx . . $ localPlayer.->setControlcxx . . $ Player#setControl(918ebd27a9ddbad3).(i, controlscxx . . $ controls..getStatecxx . . $ Controls#getState(83c267b20bac841a).(i)); |
| 813 | |
| 814 | ret = stepcxx . . $ JJ1Level#step(b126dc7c1de90089).(); |
| 815 | stepscxx . . $ Level#steps.++; |
| 816 | |
| 817 | if (ret) return ret; |
| 818 | |
| 819 | if (!multiplayercxx . . $ Level#multiplayer. && playerWasAlive && (localPlayercxx . . $ localPlayer.->getJJ1LevelPlayercxx . . $ Player#getJJ1LevelPlayer(cf23ec4c0d6db922).()->getEnergycxx . . $ JJ1LevelPlayer#getEnergy(b126dc7c1de90089).() == 0)) |
| 820 | flashcxx . . $ JJ1Level#flash(1b04462a7c7a7926).(0, 0, 0, T_ENDcxx . . $ `src/jj1/level/jj1level.h:141:9`! << 1); |
| 821 | |
| 822 | } |
| 823 | |
| 824 | |
| 825 | // Draw the graphics |
| 826 | |
| 827 | drawcxx . . $ JJ1Level#draw(49f6e7a06ebc5aa8).(); |
| 828 | |
| 829 | |
| 830 | // If paused, draw "PAUSE" |
| 831 | if (pmessage && !pmenu) |
| 832 | fontcxx . . $ JJ1Level#font.->showStringcxx . . $ Font#showString(7e50a619d5a117f1).("pause", (canvasWcxx . . $ canvasW. >> 1) - 44, 32); |
| 833 | |
| 834 | // If paused, silence music |
| 835 | pauseMusiccxx . . $ pauseMusic(b45ddcbc8423892c).(pmessage && !pmenu); |
| 836 | |
| 837 | if (stagecxx . . $ Level#stage. == LS_ENDcxx . . $ LS_END.) { |
| 838 | |
| 839 | // The level is over, so draw play statistics & bonuses |
| 840 | |
| 841 | // Apply time bonus |
| 842 | |
| 843 | if (timeBonus) { |
| 844 | |
| 845 | int bonusCount = (tickscxx . . $ Level#ticks. - prevTickscxx . . $ Level#prevTicks.) / 100; |
| 846 | if (!bonusCount) bonusCount = 1; |
| 847 | |
| 848 | if (timeBonus == -1) { |
| 849 | |
| 850 | if (tickscxx . . $ Level#ticks. < endTimecxx . . $ Level#endTime.) timeBonus = ((endTimecxx . . $ Level#endTime. - tickscxx . . $ Level#ticks.) / 60000) * 100; |
| 851 | else timeBonus = 0; |
| 852 | |
| 853 | LOG_DEBUGcxx . . $ `src/io/log.h:75:9`!("Killed %d of %d enemies, needed %d", |
| 854 | levelPlayer->getEnemies(), enemies, nEnemies[+getDifficulty()]); |
| 855 | LOG_DEBUGcxx . . $ `src/io/log.h:75:9`!("Collected %d of %d items, needed %d", |
| 856 | levelPlayer->getItems(), items, nItems); |
| 857 | |
| 858 | if (nEnemiescxx . . $ JJ1Level#nEnemies.[+cxx . . $ operator+(19ccb40277a922df).getDifficultycxx . . $ JJ1Level#getDifficulty(601dbc13202031c0).()]) { |
| 859 | enemyPercent = (levelPlayer->getEnemiescxx . . $ JJ1LevelPlayer#getEnemies(b126dc7c1de90089).() * 100) / (float) nEnemiescxx . . $ JJ1Level#nEnemies.[+cxx . . $ operator+(19ccb40277a922df).getDifficultycxx . . $ JJ1Level#getDifficulty(601dbc13202031c0).()]; |
| 860 | if (enemyPercent > 100) enemyPercent = 100; |
| 861 | } |
| 862 | if (nItemscxx . . $ JJ1Level#nItems.) { |
| 863 | itemPercent = (levelPlayer->getItemscxx . . $ JJ1LevelPlayer#getItems(b126dc7c1de90089).() * 100) / (float) nItemscxx . . $ JJ1Level#nItems.; |
| 864 | if (itemPercent > 100) itemPercent = 100; |
| 865 | } |
| 866 | |
| 867 | // FIXME: check if JJ1 shows perfect score when there are no enemies or items |
| 868 | if (enemyPercent == 100 && itemPercent == 100) { |
| 869 | perfect = 100; |
| 870 | LOG_DEBUGcxx . . $ `src/io/log.h:75:9`!("Reached a perfect (100%%) score"); |
| 871 | } |
| 872 | |
| 873 | } else if (timeBonus - bonusCount >= 0) { |
| 874 | |
| 875 | localPlayercxx . . $ localPlayer.->addScorecxx . . $ Player#addScore(d4f767463ce0a6b3).(bonusCount * 10); |
| 876 | timeBonus -= bonusCount; |
| 877 | |
| 878 | auto se = getLevelSoundcxx . . $ JJ1Level#getLevelSound(855d83035cfb1d19).(LSND_ENDCOUNTcxx . . $ `src/jj1/level/jj1level.h:115:9`!); |
| 879 | if(!isSoundPlayingcxx . . $ isSoundPlaying(856ce1a3dc69003b).(se)) |
| 880 | playSoundcxx . . $ playSound(80b838f98135e5b).(se); |
| 881 | |
| 882 | } else { |
| 883 | |
| 884 | localPlayercxx . . $ localPlayer.->addScorecxx . . $ Player#addScore(d4f767463ce0a6b3).(timeBonus * 10); |
| 885 | timeBonus = 0; |
| 886 | |
| 887 | } |
| 888 | |
| 889 | if (timeBonus == 0) { |
| 890 | |
| 891 | returnTime = tickscxx . . $ Level#ticks. + T_ENDcxx . . $ `src/jj1/level/jj1level.h:141:9`!; |
| 892 | paletteEffectscxx . . $ Level#paletteEffects. = new WhiteOutPaletteEffectcxx . . $ WhiteOutPaletteEffect#(T_ENDcxx . . $ `src/jj1/level/jj1level.h:141:9`!, paletteEffectscxx . . $ Level#paletteEffects.); |
| 893 | playSoundcxx . . $ playSound(80b838f98135e5b).(getLevelSoundcxx . . $ JJ1Level#getLevelSound(855d83035cfb1d19).(LSND_DONEcxx . . $ `src/jj1/level/jj1level.h:116:9`!)); |
| 894 | |
| 895 | } |
| 896 | |
| 897 | } |
| 898 | |
| 899 | // Display statistics & bonuses |
| 900 | |
| 901 | fontcxx . . $ JJ1Level#font.->showStringcxx . . $ Font#showString(7e50a619d5a117f1).("time", (canvasWcxx . . $ canvasW. >> 1) - 152, (canvasHcxx . . $ canvasH. >> 1) - 60); |
| 902 | fontcxx . . $ JJ1Level#font.->showNumbercxx . . $ Font#showNumber(b1146eedae1e1d0b).(timeBonus, (canvasWcxx . . $ canvasW. >> 1) + 124, (canvasHcxx . . $ canvasH. >> 1) - 60); |
| 903 | |
| 904 | fontcxx . . $ JJ1Level#font.->showStringcxx . . $ Font#showString(7e50a619d5a117f1).("enemies", (canvasWcxx . . $ canvasW. >> 1) - 152, (canvasHcxx . . $ canvasH. >> 1) - 40); |
| 905 | fontcxx . . $ JJ1Level#font.->showNumbercxx . . $ Font#showNumber(b1146eedae1e1d0b).(enemyPercent, (canvasWcxx . . $ canvasW. >> 1) + 124, (canvasHcxx . . $ canvasH. >> 1) - 40); |
| 906 | fontcxx . . $ JJ1Level#font.->showStringcxx . . $ Font#showString(7e50a619d5a117f1).("%", (canvasWcxx . . $ canvasW. >> 1) + 124, (canvasHcxx . . $ canvasH. >> 1) - 40); |
| 907 | |
| 908 | fontcxx . . $ JJ1Level#font.->showStringcxx . . $ Font#showString(7e50a619d5a117f1).("items", (canvasWcxx . . $ canvasW. >> 1) - 152, (canvasHcxx . . $ canvasH. >> 1) - 20); |
| 909 | fontcxx . . $ JJ1Level#font.->showNumbercxx . . $ Font#showNumber(b1146eedae1e1d0b).(itemPercent, (canvasWcxx . . $ canvasW. >> 1) + 124, (canvasHcxx . . $ canvasH. >> 1) - 20); |
| 910 | fontcxx . . $ JJ1Level#font.->showStringcxx . . $ Font#showString(7e50a619d5a117f1).("%", (canvasWcxx . . $ canvasW. >> 1) + 124, (canvasHcxx . . $ canvasH. >> 1) - 20); |
| 911 | |
| 912 | fontcxx . . $ JJ1Level#font.->showStringcxx . . $ Font#showString(7e50a619d5a117f1).("perfect", (canvasWcxx . . $ canvasW. >> 1) - 152, canvasHcxx . . $ canvasH. >> 1); |
| 913 | fontcxx . . $ JJ1Level#font.->showNumbercxx . . $ Font#showNumber(b1146eedae1e1d0b).(perfect, (canvasWcxx . . $ canvasW. >> 1) + 124, canvasHcxx . . $ canvasH. >> 1); |
| 914 | |
| 915 | fontcxx . . $ JJ1Level#font.->showStringcxx . . $ Font#showString(7e50a619d5a117f1).("score", (canvasWcxx . . $ canvasW. >> 1) - 152, (canvasHcxx . . $ canvasH. >> 1) + 40); |
| 916 | fontcxx . . $ JJ1Level#font.->showNumbercxx . . $ Font#showNumber(b1146eedae1e1d0b).(localPlayercxx . . $ localPlayer.->getScorecxx . . $ Player#getScore(b126dc7c1de90089).(), (canvasWcxx . . $ canvasW. >> 1) + 124, (canvasHcxx . . $ canvasH. >> 1) + 40); |
| 917 | |
| 918 | } |
| 919 | |
| 920 | |
| 921 | // Draw statistics, menu etc. |
| 922 | drawOverlaycxx . . $ Level#drawOverlay(ac8280b982de25d7).(LEVEL_BLACKcxx . . $ `src/jj1/level/jj1level.h:137:9`!, pmenu, option, 15, 47, -16); |
| 923 | |
| 924 | } |
| 925 | |
| 926 | return E_NONEcxx . . $ `src/OpenJazz.h:69:9`!; |
| 927 | |
| 928 | } |