| 1 | |
| 2 | /** |
| 3 | * |
| 4 | * @file localgame.cpp |
| 5 | * |
| 6 | * Part of the OpenJazz project |
| 7 | * |
| 8 | * @par History: |
| 9 | * - 23rd August 2005: Created level.c and menu.c |
| 10 | * - 3rd of February 2009: Renamed level.c to level.cpp and menu.c to menu.cpp |
| 11 | * - 9th March 2009: Created game.cpp from parts of menu.cpp and level.cpp |
| 12 | * - 3rd June 2009: Created network.cpp from parts of game.cpp |
| 13 | * - 18th July 2009: Created servergame.cpp from parts of game.cpp |
| 14 | * - 18th July 2009: Created clientgame.cpp from parts of game.cpp |
| 15 | * - 3rd October 2010: Created localgame.cpp from parts of game.cpp |
| 16 | * |
| 17 | * @par Licence: |
| 18 | * Copyright (c) 2005-2017 AJ Thomson |
| 19 | * |
| 20 | * OpenJazz is distributed under the terms of |
| 21 | * the GNU General Public License, version 2.0 |
| 22 | * |
| 23 | */ |
| 24 | |
| 25 | |
| 26 | #include "game.h"cxx . . $ `<file>/src/game/game.h`/ |
| 27 | #include "gamemode.h"cxx . . $ `<file>/src/game/gamemode.h`/ |
| 28 | |
| 29 | #include "player/player.h"cxx . . $ `<file>/src/player/player.h`/ |
| 30 | #include "setup.h"cxx . . $ `<file>/src/setup.h`/ |
| 31 | #include "util.h"cxx . . $ `<file>/src/util.h`/ |
| 32 | |
| 33 | |
| 34 | /** |
| 35 | * Create a single-player local game |
| 36 | * |
| 37 | * @param firstLevel File name of the first level to play |
| 38 | * @param gameDifficulty Difficulty setting |
| 39 | */ |
| 40 | LocalGamecxx . . $ LocalGame#::LocalGamecxx . . $ LocalGame#LocalGame(d100a742d84345dc). (const char *firstLevel, difficultyTypecxx . . $ difficultyType# gameDifficulty) { |
| 41 | |
| 42 | levelFilecxx . . $ Game#levelFile. = createStringcxx . . $ createString(a8b8e32347182212).(firstLevel); |
| 43 | levelTypecxx . . $ Game#levelType. = getLevelTypecxx . . $ Game#getLevelType(b61afb7421387496).(firstLevel); |
| 44 | |
| 45 | difficultycxx . . $ Game#difficulty. = gameDifficulty; |
| 46 | |
| 47 | modecxx . . $ Game#mode. = new SingleGameModecxx . . $ SingleGameMode#(); |
| 48 | |
| 49 | // Create the player |
| 50 | nPlayerscxx . . $ nPlayers. = 1; |
| 51 | localPlayercxx . . $ localPlayer. = playerscxx . . $ players. = new Playercxx . . $ Player#Player(49f6e7a06ebc5aa8).[1]; |
| 52 | localPlayercxx . . $ localPlayer.->initcxx . . $ Player#init(eadcf6f4775e9cbb).(this, setupcxx . . $ setup..characterNamecxx . . $ Setup#characterName., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, 0); |
| 53 | |
| 54 | } |
| 55 | |
| 56 | |
| 57 | /** |
| 58 | * Destroy local game |
| 59 | */ |
| 60 | LocalGamecxx . . $ LocalGame#::~cxx . . $ LocalGame#`~LocalGame`(49f6e7a06ebc5aa8).LocalGamecxx . . $ LocalGame# () { |
| 61 | |
| 62 | delete modecxx . . $ Game#mode.; |
| 63 | |
| 64 | } |
| 65 | |
| 66 | |
| 67 | /** |
| 68 | * Set the next level |
| 69 | * |
| 70 | * @param fileName The file name of the next level |
| 71 | * |
| 72 | * @return Error code |
| 73 | */ |
| 74 | int LocalGamecxx . . $ LocalGame#::setLevelcxx . . $ LocalGame#setLevel(1ef8e6ec083aabb9). (char *fileName) { |
| 75 | |
| 76 | if (levelFilecxx . . $ Game#levelFile.) delete[] levelFilecxx . . $ Game#levelFile.; |
| 77 | |
| 78 | if (fileName) { |
| 79 | |
| 80 | levelFilecxx . . $ Game#levelFile. = createStringcxx . . $ createString(a8b8e32347182212).(fileName); |
| 81 | levelTypecxx . . $ Game#levelType. = getLevelTypecxx . . $ Game#getLevelType(b61afb7421387496).(fileName); |
| 82 | |
| 83 | } else levelFilecxx . . $ Game#levelFile. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 84 | |
| 85 | return E_NONEcxx . . $ `src/OpenJazz.h:69:9`!; |
| 86 | |
| 87 | } |
| 88 | |
| 89 | |
| 90 | /** |
| 91 | * No data is sent in local games |
| 92 | * |
| 93 | * @param buffer Data that will not be sent. First byte indicates length. |
| 94 | */ |
| 95 | void LocalGamecxx . . $ LocalGame#::sendcxx . . $ LocalGame#send(f25546b61a629de7). (unsigned char *buffer) { |
| 96 | |
| 97 | (void)buffer; |
| 98 | |
| 99 | // Do nothing |
| 100 | |
| 101 | } |
| 102 | |
| 103 | |
| 104 | /** |
| 105 | * Game iteration - nothing to be done in local games |
| 106 | * |
| 107 | * @param ticks Current time |
| 108 | * |
| 109 | * @return Error code |
| 110 | */ |
| 111 | int LocalGamecxx . . $ LocalGame#::stepcxx . . $ LocalGame#step(4c679297bf94b9eb). (unsigned int ticks) { |
| 112 | |
| 113 | (void)ticks; |
| 114 | |
| 115 | // Do nothing |
| 116 | |
| 117 | return E_NONEcxx . . $ `src/OpenJazz.h:69:9`!; |
| 118 | |
| 119 | } |
| 120 | |
| 121 | |
| 122 | /** |
| 123 | * No points are assigned to teams in local games |
| 124 | * |
| 125 | * @param team Team to receive point |
| 126 | */ |
| 127 | void LocalGamecxx . . $ LocalGame#::scorecxx . . $ LocalGame#score(ac50b47256ae7414). (unsigned char team) { |
| 128 | |
| 129 | (void)team; |
| 130 | |
| 131 | // Do nothing |
| 132 | |
| 133 | } |
| 134 | |
| 135 | |
| 136 | /** |
| 137 | * Set the checkpoint |
| 138 | * |
| 139 | * @param gridX X-coordinate (in tiles) of the checkpoint |
| 140 | * @param gridY Y-coordinate (in tiles) of the checkpoint |
| 141 | */ |
| 142 | void LocalGamecxx . . $ LocalGame#::setCheckpointcxx . . $ LocalGame#setCheckpoint(3e454b8ccf442868). (int gridX, int gridY) { |
| 143 | |
| 144 | checkXcxx . . $ Game#checkX. = gridX; |
| 145 | checkYcxx . . $ Game#checkY. = gridY; |
| 146 | |
| 147 | } |