2
* OpenTyrian: A modern cross-platform port of Tyrian
3
* Copyright (C) 2007-2009 The OpenTyrian Development Team
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License
7
* as published by the Free Software Foundation; either version 2
8
* of the License, or (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24
#define SAS (sizeof(JE_ShipsType) - 4)
26
const JE_byte extraCryptKey[10] = { 58, 23, 16, 192, 254, 82, 113, 147, 62, 99 };
28
JE_boolean extraAvail;
29
JE_ShipsType extraShips;
31
JE_word extraShapeSize;
33
void JE_decryptShips( void )
35
JE_boolean correct = true;
39
for (int x = SAS - 1; x >= 0; x--)
41
s2[x] = extraShips[x] ^ extraCryptKey[(x + 1) % 10];
43
s2[x] ^= extraShips[x - 1];
44
} /* <= Key Decryption Test (Reversed key) */
47
for (uint x = 0; x < SAS; x++)
49
if (extraShips[SAS + 0] != y)
53
for (uint x = 0; x < SAS; x++)
55
if (extraShips[SAS + 1] != y)
59
for (uint x = 0; x < SAS; x++)
61
if (extraShips[SAS + 2] != y)
65
for (uint x = 0; x < SAS; x++)
67
if (extraShips[SAS + 3] != y)
73
memcpy(extraShips, s2, sizeof(extraShips));
76
void JE_loadExtraShapes( void )
78
FILE *f = dir_fopen(get_user_directory(), "newsh$.shp", "rb");
83
extraShapeSize = ftell_eof(f) - sizeof(extraShips);
84
extraShapes = malloc(extraShapeSize);
85
efread(extraShapes, extraShapeSize, 1, f);
86
efread(extraShips, sizeof(extraShips), 1, f);