-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathabstype.cpp
More file actions
151 lines (132 loc) · 7.39 KB
/
Copy pathabstype.cpp
File metadata and controls
151 lines (132 loc) · 7.39 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/*******************************************************************************
* 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 "abstype.h"
#include "ccini.h"
#include "crc.h"
#include "globals.h"
#include "vector.h"
#include <cstdio>
/***********************************************************************************************
* AbstractTypeClass::AbstractTypeClass -- Constructor for abstract type objects. *
* *
* This is the constructor for AbstractTypeClass objects. It initializes the INI name and *
* the text name for this object type. *
* *
* INPUT: name -- Text number for the full name of the object. *
* *
* ini -- The ini name for this object type. *
* *
* OUTPUT: none *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 05/22/1995 JLB : Created. *
*=============================================================================================*/
AbstractTypeClass::AbstractTypeClass(char const * ininame) :
BASECLASS(),
IniName(),
GivenName()
{
if (ininame == NULL) {
char pstr[16];
sprintf(pstr, "%08X", (unsigned int)this);
IniName = TStringID<24>(pstr);
} else {
IniName = TStringID<24>(ininame);
}
GivenName = TStringID<48>(IniName);
AbstractTypes.Add(this);
}
/***********************************************************************************************
* AbstractTypeClass::AbstractTypeClass -- Constructor for abstract type objects. *
* *
* This is the constructor for AbstractTypeClass objects. It initializes the INI name and *
* the text name for this object type. *
* *
* INPUT: name -- Text number for the full name of the object. *
* *
* ini -- The ini name for this object type. *
* *
* OUTPUT: none *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 05/22/1995 JLB : Created. *
*=============================================================================================*/
AbstractTypeClass::AbstractTypeClass(NoInitClass const & x) :
BASECLASS(x),
IniName(x),
GivenName(x)
{
}
/// <summary>
/// Removes this object type from the master type list.
/// Every abstract type adds itself to the AbstractTypes list when it is created, so it
/// must take itself back off again here or the list would be left holding a dead pointer.
/// </summary>
AbstractTypeClass::~AbstractTypeClass(void)
{
AbstractTypes.Delete(this);
}
/***********************************************************************************************
* AbstractTypeClass::Read_INI -- Reads the techno type data from the INI database. *
* *
* Use this routine to fill in the data for this techno type class object from the *
* database specified. Typical use of this is for the rules parsing. *
* *
* INPUT: ini -- Reference to the INI database that the information will be lifted from. *
* *
* OUTPUT: bool; Was the database used to extract information? A failure (false) response *
* would mean that the database didn't contain a section that applies to this *
* techno class object. *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 07/19/1996 JLB : Created. *
*=============================================================================================*/
bool AbstractTypeClass::Read_INI(CCINIClass const & ini)
{
char buffer[64];
if (ini.Section_Present(IniName)) {
ini.Get_String(IniName, "Name", GivenName, buffer, GivenName.Size());
GivenName = TStringID<48>(buffer);
return(true);
}
return(false);
}
/// <summary>
/// Writes this object type's data out to the INI database.
/// This routine is the counterpart to Read_INI. The type's own section is cleared before
/// anything is written, so no stale entries survive from an earlier save.
/// </summary>
bool AbstractTypeClass::Write_INI(CCINIClass &ini) const
{
ini.Clear(IniName);
ini.Put_String(IniName, "Name", GivenName);
return(true);
}
/// <summary>
/// Adds this object type's identity to a CRC calculation.
/// This routine is called while the game checksum is being built so that both the INI
/// name and the displayed name of the type contribute to the result.
/// </summary>
void AbstractTypeClass::Compute_CRC(CRCEngine & crc) const
{
BASECLASS::Compute_CRC(crc);
crc((const char *)IniName);
crc((const char *)GivenName);
}