-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path_warhead.cpp
More file actions
62 lines (52 loc) · 2.19 KB
/
Copy path_warhead.cpp
File metadata and controls
62 lines (52 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*******************************************************************************
* O P E N T S
*******************************************************************************
* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright 2025 Electronic Arts Inc.
* Copyright 2026 OpenTS contributors
*
* Contains material derived from Electronic Arts source code.
* Modified by OpenTS contributors, 2026.
* EA's GPLv3 Section 7 additional terms and supplemental warranty
* disclaimers apply; see LICENSE.md.
******************************************************************************/
#include "always.h"
#include "_warhead.h"
#include "vector.h"
#include "warhead.h"
/***************************************************************************
** This is the warhead data object array.
*/
DynamicVectorClass<WarheadTypeClass *> Warheads;
/// <summary>
/// Converts a warhead name into a warhead type.
/// This routine is used when the rules are read in and a warhead is referred to by name.
/// A name that has not been encountered before will have a warhead type object created
/// for it, so an unknown name is not treated as an error.
/// </summary>
/// <returns>Returns with the warhead type that matches the name. Otherwise, WARHEAD_NONE
/// is returned.</returns>
WarheadType Warhead_From_Name(char const * name)
{
if (stricmp(name, "<none>") != 0 && stricmp(name, "none") != 0) {
for (int index = WARHEAD_FIRST; index < Warheads.Count(); index++) {
if (stricmp(name, Warheads[index]->Name()) == 0) {
return(WarheadType(index));
}
}
WarheadTypeClass *ptr = new WarheadTypeClass(name);
return(WarheadType(Warheads.ID(ptr)));
}
return(WARHEAD_NONE);
}
/// <summary>
/// Fetches the name of the specified warhead.
/// This routine is used when a warhead must be written back out to an INI file or
/// displayed, since the rules refer to warheads by name rather than by index.
/// </summary>
/// <returns>Returns with a pointer to the warhead's name. Otherwise, NULL is returned.</returns>
char const * Warhead_Name(WarheadType warhead)
{
if (warhead == WARHEAD_NONE || (unsigned)warhead >= (unsigned)Warheads.Count()) return(NULL);
return(Warheads[warhead]->Name());
}